I want to use SLF4J for logging instead of commons-logging. How do I configure?
I want to use SLF4J for logging instead of commons-logging. How do I configure?
No way. Commons-logging is the only Spring hard dependency.
To be more precious you may use SLF4J in your own code, but you still need commons-logging for Spring itself.
There is a way.
You could always update the Spring source and recompile.
With global search and replace this wouldn't be such a big deal.
Just use the SLF4J jcl104-over-slf4j jar as a drop-in replacement for the commons-logging jar. With this you can get all the benefits of SLF4J and still use the exact same commons-logging API - ie no changes in your code.
If you use Maven, the dependency is as follows:
AlanCode:<dependency> <groupId>org.slf4j</groupId> <artifactId>jcl104-over-slf4j</artifactId> <version>1.4.2</version> </dependency>
I don't think the version matters too much, as we haven't had a problem, moreover, the API from 1.0.4 to 1.1 is little different and slf4j is providing the engine underneath anyway. However, commons-logging 1.1 (and 1.1.1) are supposed to fix the class loading issues that have caused people to move away from it to frameworks like slf4j. I'm going to try it out and see how it goesThere is one problem - Spring relies on commons-logging 1.1, not 1.0.4,
so I'm not sure that suggested drop-in would suffice.
Alan
Last edited by Alan Stewart; Aug 6th, 2007 at 05:43 PM.