We use slf4j + logback, and happened to have some third-party libraries which use commons-logging. How do I set it up to use logback?
4 Answers
The answer is to not use commons-logging.jar, since SLF4J was designed to do what commons-logging does but better. As @MahdeTo refers to, you need to use jcl-over-slf4j.jar.
Check out the documentation from the slf4j website on migrating from commons-logging.

- 11,665
- 2
- 41
- 54

- 8,381
- 3
- 28
- 45
-
46Didn't you read the question? They are using third party libraries which use commons logging. – James Roper Jul 24 '12 at 09:40
-
7Indeed. But you can save the pedantic and strictest literal reading to see that I meant that the OP shouldn't use the commons-logging.jar. The OP got that, so why the need to add a non-constructive comment? – Spencer Kormos Jul 26 '12 at 21:08
-
4Please also check the FAQ of SLF4J, which show how commons-logging can be excluded from the maven dependencies: http://slf4j.org/faq.html#excludingJCL – koppor Nov 12 '12 at 20:03
-
LOL at the person that down-voted this answer, and without explaining why. Great job at not understanding the subject of the question, and the platform on which it was asked, all at the same time. – Spencer Kormos Jan 25 '15 at 00:26
-
1Suggested edit: instead of "The answer is to not use commons-logging" make it "The answer is to not use commons-logging.jar". – Roger Nov 18 '15 at 19:44
-
I think this is clear. "don't use commons-logging" - but use another library that implements the api. ps. let's be civil, people! – vikingsteve Jan 10 '17 at 14:39
-
2So I don't get a "LOL at the person that down-voted this answer, and without explaining why", see the upvoted comments for why. – Roy Truelove Jan 18 '17 at 02:45
I come across this question too, and found out jcl-over-slf4j.jar
indeed can solve the problem, I couldn't understand that why commons-logging
couldn't use logback
automatically, since commons-logging
is log interface and logback
is implementation, they should integrate automatically, until I found this:
The Apache Commons Logging (JCL) provides a Log interface that is intended to be both light-weight and an independent abstraction of other logging toolkits. It provides the middleware/tooling developer with a simple logging abstraction, that allows the user (application developer) to plug in a specific logging implementation.
JCL provides thin-wrapper Log implementations for other logging tools, including Log4J, Avalon LogKit (the Avalon Framework's logging infrastructure), JDK 1.4, and an implementation of JDK 1.4 logging APIs (JSR-47) for pre-1.4 systems. The interface maps closely to Log4J and LogKit.
Obviously not all the log interface can integrate nicely with log implementation which mean, if you really want to use logback
, jcl-over-slf4j.jar
is your only solution now because JCL
only support Log4J, Logkit, JDK 1.4
.

- 10,725
- 19
- 102
- 158
Just add jcl-over-slf4j
to the dependencies of your project (check current version at https://search.maven.org/search?q=g:org.slf4j%20AND%20a:jcl-over-slf4j&core=gav)

- 21,149
- 6
- 87
- 74
for those all who wants to keep the final package size smaller; checkout
mvn dependency:tree
result of your project and if any dependency to commons-logging
exists, exclude them as well. Since the jcl-over-slf4j.jar
contains both Log and LogFactory classes with exact same package structure, these commons-logging jars will be extra on your final package.

- 2,519
- 4
- 32
- 46
-
2this answer is not only for "those all who wants to keep the final package size smaller", but it is a must-do for everyone who wants to use jcl-over-slf4j – mirec Aug 28 '19 at 11:40