Uploaded image for project: 'JBoss Logging'
  1. JBoss Logging
  2. JBLOGGING-65

JBoss Logging fails to support log4j-over-slf4j

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 3.0.0.GA
    • 3.0.0.Beta5-jboss-logging
    • None
    • None
    • Hide

      Run app with JBoss Logging dependency (say, Infinispan 5.x) and ensure log4j is excluded from classpath. Replace with log4j-over-slf4j, slf4j-api, and slf4j logging engine (or adapter) of your choice. JBoss Logging will select log4j instead of slf4j, even though log4j is not in the classpath.

      Show
      Run app with JBoss Logging dependency (say, Infinispan 5.x) and ensure log4j is excluded from classpath. Replace with log4j-over-slf4j, slf4j-api, and slf4j logging engine (or adapter) of your choice. JBoss Logging will select log4j instead of slf4j, even though log4j is not in the classpath.

      org.jboss.logging.LoggerProviders tests for the existence of org.apache.log4j.LogManager and if it discovers it assumes Log4j is in use. This is incorrect in the scenario where log4j events are routed to slf4j for eventual routing to another logging engine (a very common use case). This engine may be Logback, but may not. Therefore, the test for whether slf4j is in use is not whether Logback is in the classpath (Logback is AN implementation of slf4j, not THE implementation...), but whether org.slf4j.impl.StaticLoggerBinder is. There should be no attempt to detect Logback itself. JBoss Logging cannot tell through simply loading org.apache.log4j.LogManager whether this class is provided by log4j or by log4j-over-slf4j so cannot use this class to detect log4j use. To clarify, the logic should be:

      1) If org.slf4j.impl.StaticLoggerBinder is available, use slf4j.
      2) If org.apache.log4j.LogManager (but not StaticLoggerBinder) is available, use log4j.
      3) Otherwise use java.util.logging

              dlloyd@redhat.com David Lloyd
              jramsdale Jeff Ramsdale (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: