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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0-beta9, 2.0-rc1
    • 2.5
    • Core
    • tomcat 7.0.42

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

      Attachments

        Issue Links

          Activity

            People

              rpopma Remko Popma
              kireet Kireet Reddy
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: