Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eliminating unnecessary log4j setup output

I'm using log4j in an app I'm developing to eventually run inside Tomcat/JBoss, but right now I'm running it from inside Eclipse. I've configured it to write to a ConsoleAppender using a log4j.xml file and passed it as a system property, and all of my logging output works.

The problem is that log4j spits out a bunch of bootstrap/startup garbage that I really don't need (or want) to see. For example:

log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [CoherenceMonitor] additivity to [false].
log4j: Level value for CoherenceMonitor is  [DEBUG].
log4j: Desired Level sub-class: [org.apache.log4j.Level]
log4j: CoherenceMonitor 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].
log4j: Adding appender named [console] to category [CoherenceMonitor].

I get about 20 lines of this every time I run my program, and it's just noise that obscures the log data I really care about. What I want to do is suppress this output (everything that starts with "log4j:") and only include output from my own logging statements.

I've tried everything I could find via Google and my coworkers, including setting a priority value for the org.apache category as shown below. (Regardless of the priority I set, I still get the output.)

<category name="org.apache">
    <priority value="FATAL"/>
</category>

I'm pretty novice at log4j configuration, and mine is pretty simple. I have only one appender, one logger, and this one category. Any help on getting log4j to just keep its mouth shut while it's doing setup would be much appreciated! :-)

like image 593
Quinn Taylor Avatar asked Jul 07 '09 22:07

Quinn Taylor


1 Answers

Besides checking if your log4j.xml has the debug="true" attribute, also make sure that you do not have the log4j.debug system parameter set (in Eclipse this would appear in the Run Configuration as JVM argument with the value of -Dlog4j.debug).

like image 134
matt b Avatar answered Oct 03 '22 02:10

matt b