Wednesday, July 8, 2009

Eliminating unnecessary log4j setup output

When using log4j for logging in your application, you may see a lot of log messages added by log4j when startup of the application which are not required. These will add to noise in your log files.

They will look something like

log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [Myclass] additivity to [false].
log4j: Level value for Myclass is [DEBUG].
log4j: Desired Level sub-class: [org.apache.log4j.Level]
log4j: Myclass level set to DEBUG
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Setting property [target] to [System.out].
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%-5p %m%n].

These are the debug information from the logger itself. If you are using the XML config it looks like this:

log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"
Turn the debug to false.

No comments: