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

JUL bridge broken

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.6
    • JUL adapter
    • None

    Description

      org.apache.logging.log4j.jul.ApiLogger doesnt behave the same depending where we come from (logger.info() vs logger.log() typically)

      The main difference is the message factory used.

      for this statement:

      logger.info("{foo}");
      

      a SimpleMessage will be emitted but for

      logger.log(recordWithSameContent);
      

      a MessageFormatMessage will be emitted making the log statement failling.

      org.apache.logging.log4j.jul.ApiLogger#log(java.util.logging.LogRecord) should be reworked to handle such a case.

      Here how to reproduce it:

      Logger.getLogger("foo").info("{test}");
      Logger.getLogger("foo").log(new LogRecord(Level.INFO, "{test}"));
      

      The fix is as simple as testing org.apache.logging.log4j.jul.ApiLogger#log(java.util.logging.LogRecord) and if null don't call logger.getMessageFactory().newMessage(record.getMessage(), record.getParameters()) but logger.getMessageFactory().newMessage(record.getMessage())

      Attachments

        1. LOG4J2-1251___2.patch
          8 kB
          Romain Manni-Bucau
        2. LOG4J2-1251.patch
          8 kB
          Romain Manni-Bucau

        Issue Links

          Activity

            People

              mattsicker Matt Sicker
              romain.manni-bucau Romain Manni-Bucau
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: