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

log4j-to-slf4j: Messages are formatted twice if there happen to be a `{}` in the parameters

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.11.1, 2.11.2
    • Fix Version/s: None
    • Component/s: API
    • Labels:
    • Environment:

      MacOS Majave

      Java 1.8

      log4j2

      logback

      Description

      As says in the summary. If we do

      logger.info("Message: {}", "Test - {}")
      

      The final message is

      Message: Test - Test - {}
      

      Which should be

      Message: Test - {}
      

      See the code at log4j-to-slf4j-test.

      After some investigation, I think the reason may lies in
      log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger#logMessage

      locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), message.getFormattedMessage(),
      message.getParameters(), t);
      

      The String returned by message.getFormattedMessage() is already formatted.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              lasyard Yueguang Jiao
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: