Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.6
    • Component/s: JUL adapter
    • Labels:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: