Description
Juergen Hoeller opened SPR-14512 and commented
Following up on recent discussions about the good old Commons Logging vs SLF4J conflict (a manual exclusion needed in the POM etc) and the recent attractiveness of Log4J 2's logging API:
Let's revisit our logging API arrangement. A straight migration to SLF4J doesn't seem to be a worthwhile option from a 2017 perspective, in particular since Log4J 2 actually has a nicer API. However, a straight migration to Log4J 2 isn't ideal either since so many people use SLF4J at the moment. And of course, none of those "simple" migration options addresses the problem of backwards compatibility with Spring extensions which happen to use our exposed protected logger reference... which is a hard Commons Logging reference in pre-compiled binaries.
Beyond a straight migration, we may also introduce our own logging abstraction (sigh). Alternatively, we could ship a variant of the Commons Logging API in our own spring-core.jar
, controlling the target binding through our own adaptive setup logic: This is essentially what the JCL-over-SLF4J adapter does, and it seems to work fine there. As long as we're able to bind to java.util.logging
, SLF4J and Log4J 2 without too much hassle (ideally through autodetection in the classpath), it might be a sweet compromise for the backwards compatibility issue.
Of course, it would also be nice to have a richer logging API available for our internal purposes. Log4J 2 looks quite attractive there but we might not want to require it at runtime, in particular for SLF4J users or java.util.logging
users in application server environments. We could also use a facade of our own internally or augment our variant of Commons Logging accordingly.
Affects: 5.0 M1
Issue Links:
- Revisit subsystem-oriented logging [SPR-8122] #12774 Revisit subsystem-oriented logging
- Migrate logger from commons-logging to slf4j (remove commons-logging dependency) [SPR-6607] #11273 Migrate logger from commons-logging to slf4j (remove commons-logging dependency)
- DATACMNS-1040 Remove exclusion for Commons Logging
- spring-core source jar contains two copies of source code [SPR-15462] #20022 spring-core source jar contains two copies of source code
- Consider migrating from Commons-Logging to SLF4j [SPR-5327] #10000 Consider migrating from Commons-Logging to SLF4j
- commons-logging LogFactory and String arguments [SPR-16226] #20774 commons-logging LogFactory and String arguments
- Fix compilation warning on JDK 9: use deprecated method LogRecord.setMillis [SPR-15453] #20014 Fix compilation warning on JDK 9: use deprecated method LogRecord.setMillis
- Remove duplicate commons logging classes from spring-jcl [SPR-16062] #20611 Remove duplicate commons logging classes from spring-jcl
- spring-jcl routes logging inefficiently against SLF4J with log4j-to-slf4j setup [SPR-17586] #22118 spring-jcl routes logging inefficiently against SLF4J with log4j-to-slf4j setup
0 votes, 11 watchers