Potential Logging/Log4j Clobbering Situation
I have two webapps deployed to Tomcat. The service is started with -Dlog4j.configuration=log4j.properties in catalina.sh
At times I'm noticing that only one of the webapps is logging to the file. I restart Tomcat and both are logging again. Any ideas on what the conflict might be? Shouldn't this be a supported configuration since both ap开发者_StackOverflow社区ps are running in the same JVM, with a global configuration?
The only thing I can think of that might be interfering is the CXF log config: META-INF/cxf/org.apache.cxf.Logger
update
I found that both webapps are still logging, but one webapp is logging to a different position in the file, so I'll see something like
1:59PM - xx 2:00PM - xxxx 1:45PM - xxx
etc.
Sometimes it will be logging to a rolled file.
I have no idea why this happens, but you can insert some debugging code being triggered to see what's going on when logging fails. Something like this (code untested!):
Category logger = Logger.getLogger(yourClass);
do {
Level level = logger.getLevel();
System.out.println("Log level of " + logger + " is " + level + ". Appenders:");
for (Enumeration appenders = logger.getAllAppenders() ; appenders.hasMoreElements() ;) {
System.out.println(appenders.nextElement());
}
logger = logger.getParent();
} while (logger != Logger.getRootLogger())
It is somewhat ironic to debug log4j with System.out.println
, but it would do the job (it's a throw-away code anyway).
精彩评论