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

Handle some unchecked exceptions while loading plugins

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.8.2
    • 3.0.0, 2.11.2
    • Plugins
    • None

    Description

      The PluginRegistry handles ClassNotFoundException ] but does not handle unchecked exceptions like NoClassDefFoundError. As a result applications may not start when loading of a plugin fails with an unchecked exception.

       

      Here is the scenario we ran into:

       

      We use logstash-gelf in a standardized Tomcat docker images to send Java Util Logging (as used by Tomcat) to Graylog. To do this we add the logstash-gelf jar to the $CATALINA_HOME/lib directory, effectively placing it on Tomcat's common loader classpath. In essence there is no log4j involved, but the logstash-gelf jar contains integrations for various logging frameworks, including a log4j2 appender.

      When a webapplication that is deployed on this Tomcat instance uses log4j2 as logging framework the logstash-gelf appender is found during plugin scanning and the PluginRegistry tries to load it (even if the appender is not used in the log4j configuration). The logstash-gelf plugin is not loaded via the webapplication classloader, but through the parent common loader. It can find the plugin class but not the dependent log4j2 classes as they are only on the classpath of the webapplication classloader:

       

      java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/appender/AbstractAppender
      

       

       

      Attachments

        Activity

          People

            ggregory Gary D. Gregory
            rswart rswart
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: