Logger definitions

You use a <Logger> element in file log4j-2.xml to define configuration parameters for an associated <RollingFile> appender. Using a <Logger> element, you can set the logging level for a specific logging category associated with an appender, for example.

The following code samples illustrate this concept. In the first code sample, the <RollingFile> appender defines a file to store log messages generated by the Rule Engine as it executes Gosu in the application server. PolicyCenter then writes all messages sent to any of the RuleEngine.* logging categories to this log file.

<RollingFile name="RuleEngineLog" fileName="${guidewire.logDirectory}/ruleengine.log"
      filePattern="${guidewire.logDirectory}/ruleengine.log%d{.yyyy-MM-dd}">
  <PatternLayout pattern="${file.defaultPattern}" charset="UTF-8"/>
  <TimeBasedTriggeringPolicy/>
</RollingFile>

The following associated <Logger> element sets several configuration parameters related to the <RuleEngineLog> appender.

<Logger name="RuleEngine" additivity="false" level="info">
  <AppenderRef ref="RuleEngineLog"/>
</Logger>

Notice the following:

  • The name attribute defines the name of this <Logger> element.
  • The additivity attribute value of false disables logging additivity, meaning that PolicyCenter does not propagate the logging message to any parents of the logging category.
  • The level attribute sets the logging level to info for all appenders that inherit from the RuleEngine appender. For example, a logging category of <RuleEngineLog.Gosu> inherits the info log level from the parent <RuleEngineLog> appender, unless you specifically set the logging level elsewhere.
  • The ref attribute specifies the name of the associated appender.
Refer to the following Apache documentation for more information.