Details
Description
This ticket tracks Async Logger issues in Tomcat when making all loggers async with LoggerContextSelector system property. For Tomcat issues with AsyncRoot/AsyncLogger in the configuration file, see |
When redeploying my application in tomcat multiple times, I get an exception:
Exception in thread "Thread-29" java.lang.NullPointerException
at org.apache.logging.log4j.core.async.AsyncLogger.stop(AsyncLogger.java:249)
at org.apache.logging.log4j.core.async.AsyncLoggerContext.stop(AsyncLoggerContext.java:56)
at org.apache.logging.log4j.core.LoggerContext$ShutdownThread.run(LoggerContext.java:437)
This seems to be due to the fact that some initialization code happens in the class initializer but is undone in the stop() method which is called during webapp undeployment. This causes issues because in this case the log4j jar is loaded by the shared classloader ($catalina.home/lib) rather than the webapp classloader. This means the AsyncLogger class is not re-created during webapp deployment.
I am using this structure because I have many 3rd party libraries and want to keep redeployments lightweight.
Attachments
Issue Links
- incorporates
-
LOG4J2-323 ThreadLocal-leak on tomcat shutdown when using async logging
-
- Resolved
-
- is related to
-
LOG4J2-1172 ThreadLocal leak [AsyncLogger$Info] on Tomcat when using AsyncLoggerContextSelector
-
- Resolved
-
- relates to
-
LOG4J2-1171 LoggerContext names in web apps are cryptic
-
- Resolved
-