[JIRA] (SLF4J-421) LoggerWrapper and subclasses perform argument substitution twice

[ https://jira.qos.ch/browse/SLF4J-421?page=com.atlassian.jira.plugin.system.i... ] Jonathan Esssex commented on SLF4J-421: --------------------------------------- I just submitted a PR for this
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 Fix For: 2.0.0-alpha2
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] ReproduceSlf4jBug - foo,[{}] // Actual [ERROR] ReproduceSlf4jBug - foo,[foo] {code} {code:java|title=Brackets First|borderStyle=solid} log.error("{},{}", "[{}]", foo); // Expected [ERROR] ReproduceSlf4jBug - [{}],foo // Actual [ERROR] ReproduceSlf4jBug - [[{}]],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)
participants (1)
-
QOS.CH (JIRA)