I'm trying to set up log4j in my app and one of my third party JARs seems to somehow keep turning my log level to "OFF". It only happens when code from that library is executed. I don't know how it can do this because I'm not using a logger it knows the name of, and I'm not using the root logger. I've spent 5 hours on this and so far my only achievement has been to acquire a frustration level of over 9000.
I'm using the latest Tomcat (7.0.37) on windows 7 64 bit, Java 6 u23.
log4j.properties:
log4j.logger.com.foo.bar.SearchAndReport=TRACE, stdout, file
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=D:/logTest.log
log4j.appender.file.MaxFileSize=100KB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%p] %d{dd MMM yyyy HH:mm:ss,SSS} - %C{2}.%M() - %m %n
then in my Servlet for testing I have:
Logger log = Logger.getLogger(SearchAndReport.class);
System.out.println(log.getLevel());
This code runs every time a DoPost or DoGet is run, and the level stays on the level I set (TRACE) until the third party code runs and turns it to off.
My questions are:
- How can another logger interfere with a logger I've named and set up myself?
- How can I stop this happening, and force the level I set?
Thanks :)