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

ThreadContextDataInjector Uses Incorrect Providers Under Tomcat

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.17.1
    • None
    • Core, Web/Servlet
    • None
    • Tomcat 9.0.58 with the following jars in ${CATALINA_HOME}/lib:

      log4j-api-2.17.1.jar

      log4j-core-2.17.1.jar

      log4j-jul-2.17.1.jar

      JUL LogManager is org.apache.logging.log4j.jul.LogManager

    Description

      We are using Log4j with tomcat by including it in the boot classpath and using Log4jServletContextListener in the web.xml. We are also using the log4j JUL LogManager. Web application ContextDataProviders are not being loaded correctly.

      I think this is because ThreadContextDataInjector::getServiceProviders is sensitive to the web application classpath, but the class, which is shared between the web applications and tomcat, statically caches the result. The providers list for tomcat is initialized first and is thus incorrectly used for the web applications.

      Attachments

        Activity

          People

            Unassigned Unassigned
            davehawkins Dave Hawkins
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: