You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Yueguang Jiao (JIRA)" <ji...@apache.org> on 2019/06/03 08:16:00 UTC

[jira] [Created] (LOG4J2-2623) log4j-to-slf4j: Messages are formatted twice if there happen to be a `{}` in the parameters

Yueguang Jiao created LOG4J2-2623:
-------------------------------------

             Summary: log4j-to-slf4j: Messages are formatted twice if there happen to be a `{}` in the parameters
                 Key: LOG4J2-2623
                 URL: https://issues.apache.org/jira/browse/LOG4J2-2623
             Project: Log4j 2
          Issue Type: Bug
          Components: API
    Affects Versions: 2.11.2, 2.11.1
         Environment: MacOS Majave

Java 1.8

log4j2

logback
            Reporter: Yueguang Jiao


As says in the summary. If we do
{code:java}
logger.info("Message: {}", "Test - {}")
{code}
The final message is
{code:java}
Message: Test - Test - {}
{code}
Which should be
{code:java}
Message: Test - {}
{code}
See the code at [log4j-to-slf4j-test|https://github.com/lasyard/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
{code:java}
locationAwareLogger.log(getMarker(marker), fqcn, convertLevel(level), message.getFormattedMessage(),
message.getParameters(), t);
{code}
The String returned by message.getFormattedMessage() is already formatted.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)