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

log4j-1.2 compatibility layer seems to rely on log4j-core . It shouldn't

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Duplicate
    • 2.12.0
    • None
    • Log4j 1.2 bridge
    • None

    Description

      I've just got a surprise that was a showstopper to me: It seems that log4j 1.2 compatibility layer demands log4j core for working well:

      In our project, we are trying to use another spi that wraps around log4j 2 , so that some specific features can be enforced.

      However, when I try to use log4j 1.2 compatibility layer, it fails:

       

      Exception in thread "main" java.lang.ClassCastException: com.ibm.is.poclog4j.commonconfig.MandatoryAppendersLoggerContext incompatible with org.apache.logging.log4j.core.LoggerContext
          at org.apache.log4j.Logger$PrivateManager.getContext(Logger.java:59)
          at org.apache.log4j.Logger.getRootLogger(Logger.java:45)
          at com.ibm.is.poclog4j.sample.SampleLogUser.main(SampleLogUser.java:9)

       

      The issue is there: org.apache.logging.log4j.core.LoggerContext : you shouldn't count with a core-based context, or else you violate the API contract, forcing people to use a specific implementation for log4j (in this case, the default core one).

      My SPI uses the spi-provided interface for LoggingContext:
      import org.apache.logging.log4j.spi.LoggerContext;

      public class MandatoryAppendersLoggerContext implements LoggerContext {

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              abpicoli_br Alexander Picoli
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: