Details
-
Bug
-
Resolution: Fixed
-
Major
-
1.7.x
-
Java 8; haven't tested with earlier versions or Java 9.
Description
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.
log.error("{},{}", foo, "[{}]"); // Expected [ERROR] ReproduceSlf4jBug - foo,[{}] // Actual [ERROR] ReproduceSlf4jBug - foo,[foo]
log.error("{},{}", "[{}]", foo); // Expected [ERROR] ReproduceSlf4jBug - [{}],foo // Actual [ERROR] ReproduceSlf4jBug - [[{}]],foo
In the attached tests, a basic org.slf4j.Logger is tested with the same arguments to provide a reference.
Attachments
Issue Links
- subsumes
-
SLF4J-287 LocLogger confuses empty Map as a {} placeholder
- Closed
- links to