You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Piotr Karwasz (Jira)" <ji...@apache.org> on 2022/07/28 20:25:00 UTC

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

     [ https://issues.apache.org/jira/browse/LOG4J2-2623?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Piotr Karwasz resolved LOG4J2-2623.
-----------------------------------
    Resolution: Fixed

Thanks [~ckozak], I am marking it as duplicate.

> 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: Log4j-to-SLF4J
>    Affects Versions: 2.11.1, 2.11.2, 2.14.1
>         Environment: MacOS Majave
> Java 1.8
> log4j2
> logback
>            Reporter: Yueguang Jiao
>            Assignee: Piotr Karwasz
>            Priority: Major
>              Labels: easyfix
>
> 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/code-java-maven/blob/main/utils/src/test/java/io/github/lasyard/utils/Log4jToSlf4jTest.java].
> 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
(v8.20.10#820010)