I have a Java EE application running under Glassfish.
After some recent changes we started seeing a spew of statements in our logs:
[#|2011-12-16T11:20:27.007-0800|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=19;_ThreadName=Thread-62;|2011-12-16 11:20:27,007 DEBUG org.apache.commons.httpclient.HttpConnection[Thread-62] - enter HttpConnection.closeSockedAndStreams()
|#]
[#|2011-12-16T11:20:32.007-0800|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=19;_ThreadName=Thread-62;|2011-12-16 11:20:32,007 DEBUG org.apache.commons.httpclient.HttpConnection[Thread-62] - enter HttpConnection.close()
We have set log4j.properties in an attempt to silence these
log4j.logger.org.apache.commons.httpclient=WARN
But that doesn’t work. How can I find the source or origin of these log statements? What I think I want is like a stack trace that shows me what code is being called to cause this log statement.
Maybe something in here will help? http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html
More importantly, how can I shut these statements up? They’re polluting our logs.
The solution to this is much simpler than I expected.
I found out that I can pass this argument
-Dlog4j.debug=trueto the JVM. It will make log4j tell me where it loads its configuration from.It looks like this:
I found that JAR in my classpath was packaged with a log4j.properties file (SLOPPY!) that had the root logger set to TRACE.