Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-493

Problem with AsyncLogger when web app is deployed/undeployed multiple times


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta9, 2.0-rc1
    • Fix Version/s: 2.5
    • Component/s: Core
    • Labels:
    • Environment:

      tomcat 7.0.42


      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 LOG4J2-323.

      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.


          Issue Links



              • Assignee:
                rpopma Remko Popma
                kireet Kireet Reddy
              • Votes:
                2 Vote for this issue
                6 Start watching this issue


                • Created: