Configuring Apache Log4J log files

You can configure the batch processor to use Apache Log4J log files, and also configure the level of detail recorded in the logs.

About this task

Apache Log4J log files have the following predefined logging levels:

  • ALL – log all messages.
  • DEBUG – log all debug level messages and above.
  • INFO – log all informational level messages and above.
  • WARN – log all warning level messages and above.
  • ERROR – log all error level messages and above.
  • FATAL – log only fatal error messages.
  • OFF – disable logging.

To configure Log4J log files:

Procedure

  1. To set the logging type to Apache Log4J:
    1. Edit the DWLLog.properties file.
    2. Change the value of the LoggerFactory property to com.dwl.base.logging.DWLLog4jLoggerFactory:
      LoggerFactory=com.dwl.base.logging.DWLLog4jLoggerFactory
    Note: By default, Log4J is defined as the logging type.
  2. To configure the detail level of the messages that are displayed on the console during batch processing:
    1. Edit the Log4J2.properties file.
    2. Depending on the logging level you wish to set, change the value of the appender.console.filter.threshold.level property to one of the predefined logging levels.
      appender.console.filter.threshold.level = warn
      Tip: If you wish to turn off console output so that the user can have a clear console, change the value of appender.console.filter.threshold.level to off.
  3. To configure the detail level of the messages that are logged in the batch processing log files:
    1. Edit the Log4J2.properties file.
    2. Depending on the logging level you wish to set for each log file type, change the value of the following logging level properties to one of the predefined logging levels:
      • Batch log:
        appender.file.type = RollingFile
        appender.file.name = FILE
        appender.file.fileName = ${filepath}/logs/Batch.log
        appender.file.filePattern = ${filepath}/logs/Batch-%i.log
        appender.file.layout.type = PatternLayout
        appender.file.layout.pattern = %d %-5p %3x - %m%n
        appender.file.filter.threshold.type = ThresholdFilter
        appender.file.filter.threshold.level = debug
        appender.file.layout.charset=UTF-8
        appender.file.policies.type = Policies
        appender.file.policies.size.type = SizeBasedTriggeringPolicy
        appender.file.policies.size.size = 10MB
        appender.file.strategy.type = DefaultRolloverStrategy
        appender.file.strategy.max = 10
        Note: The Batch log records all batch output. All messages written to all log files are also written to this log file.
        Tip: Change the logging level of the Batch log to error so that it only tracks error messages.
      • Activity log:
        appender.bulkProcessingActivity.type = RollingFile
        appender.bulkProcessingActivity.name = BULKPROCESSINGACTIVITY
        appender.bulkProcessingActivity.fileName = ${filepath}/logs/Activity.log
        appender.bulkProcessingActivity.filePattern=${filepath}/Activity-%i.log
        appender.bulkProcessingActivity.layout.type = PatternLayout
        appender.bulkProcessingActivity.layout.pattern = %d %-5p %3x - %m%n
        appender.bulkProcessingActivity.filter.threshold.type = ThresholdFilter
        appender.bulkProcessingActivity.filter.threshold.level = debug
        appender.bulkProcessingActivity.layout.charset = UTF-8
        appender.bulkProcessingActivity.policies.type = Policies
        appender.bulkProcessingActivity.policies.size.type = SizeBasedTriggeringPolicy
        appender.bulkProcessingActivity.policies.size.size = 10MB
        appender.bulkProcessingActivity.strategy.type = DefaultRolloverStrategy
        appender.bulkProcessingActivity.strategy.max = 10