[slf4j-dev] [JIRA] (SLF4J-421) LoggerWrapper and subclasses perform argument substitution twice
QOS.CH (JIRA)
noreply-jira at qos.ch
Wed Nov 22 21:06:00 CET 2017
Kristin Clemens created SLF4J-421:
-------------------------------------
Summary: 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
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.
h2. Example 1, Brackets Second
{code:java|borderStyle=solid}
log.error("{},{}", foo, "[{}]");
{code}
{code:title=Expected Output}
[ERROR] ReproduceLog4j2Bug - foo,[{}]
{code}
{code:title=Actual Output}
[ERROR] ReproduceLog4j2Bug - foo,[foo]
{code}
h2. Example 2, Brackets First
{code:java|borderStyle=solid}
log.error("{},{}", "[{}]", foo);
{code}
{code:title=Expected Output}
[ERROR] ReproduceLog4j2Bug - [{}],foo
{code}
{code:title=Actual Output}
[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