-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Gary Russell opened SPR-16226 and commented
@SpringBootApplication
public class Slf4jApplication {
private static final Log commonsLogger = LogFactory.getLog(Slf4jApplication.class);
private static final Logger slf4jLogger = LoggerFactory.getLogger(Slf4jApplication.class);
public static void main(String[] args) {
Map<?, ?> emptyMap = new HashMap<>();
String message = "map contents: " + emptyMap.toString();
commonsLogger.warn(message);
slf4jLogger.warn(message);
}
}
Results in an improper argument expansion due to Log4j internal use of ReusableObjectMessage
.
11:40:05.265 [main] WARN com.example.Slf4jApplication - map contents: map contents: {}
11:40:05.267 [main] WARN com.example.Slf4jApplication - map contents: {}
If log4j-api is on the class path.
If LogFactory.Log4jLog
methods tested for a String
and called the appropriate method, Log4j would use a ReusableSimpleMessage
instead, which doesn't suffer from this problem.
Affects: 5.0.1
Issue Links:
- spring-jcl does not include exported packages of java commons logging [SPR-15957] #20509 spring-jcl does not include exported packages of java commons logging
- Revisit Commons Logging vs java.util.logging vs SLF4J vs Log4j 2 [SPR-14512] #19081 Revisit Commons Logging vs java.util.logging vs SLF4J vs Log4j 2
Referenced from: commits 93f17da
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug