[slf4j-dev] [JIRA] (SLF4J-421) LoggerWrapper and subclasses perform argument substitution twice
QOS.CH (JIRA)
noreply-jira at qos.ch
Wed Nov 22 21:13:00 CET 2017
[ https://jira.qos.ch/browse/SLF4J-421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18978#comment-18978 ]
Kristin Clemens commented on SLF4J-421:
---------------------------------------
I believe this is the problem behind https://jira.qos.ch/browse/SLF4J-287, as that's how we discovered the bug in our project. When logging the entry of two maps, the first non-empty, the second empty, it appeared as though the second map had the same contents as the first map.
> LoggerWrapper and subclasses perform argument substitution twice
> -----------------------------------------------------------------
>
> Key: SLF4J-421
> URL: https://jira.qos.ch/browse/SLF4J-421
> Project: SLF4J
> Issue Type: Bug
> Components: slf4j-ext
> Affects Versions: 1.7.x
> Environment: Java 8; haven't tested with earlier versions or Java 9.
> Reporter: Kristin Clemens
> Assignee: SLF4J developers list
> Labels: logging, substitution
> Attachments: log4j2.xml, ReproduceSlf4jExtBug.java, results.txt
>
>
> If a String containing "{}" (alone or with other characters) is passed to a LoggerWrapper log method that takes a format string and arguments, or to a subclass method that follows the same pattern, a situation can occur where an argument is substituted into the place of the argument containing the substitution brackets. That argument may be another string preceding the string with brackets, or if the string with brackets is first, it may be that argument itself.
> This also occurs with log methods following this pattern even when a string format message is not expected, such as with XLogger entry and exit methods or LoggerWrapper single argument methods.
> It's hard to describe, effectively, so I'll provide some examples and test cases to help.
> {code:java|title=Brackets Second|borderStyle=solid}
> log.error("{},{}", foo, "[{}]");
> // Expected
> [ERROR] ReproduceLog4j2Bug - foo,[{}]
> // Actual
> [ERROR] ReproduceLog4j2Bug - foo,[foo]
> {code}
> {code:java|title=Brackets First|borderStyle=solid}
> log.error("{},{}", "[{}]", foo);
> // Expected
> [ERROR] ReproduceLog4j2Bug - [{}],foo
> // Actual
> [ERROR] ReproduceLog4j2Bug - [[{}]],foo
> {code}
> *In the attached tests, a basic org.slf4j.Logger is tested with the same arguments to provide a reference.*
--
This message was sent by Atlassian JIRA
(v7.3.1#73012)
More information about the slf4j-dev
mailing list