I am building a dirt-simple application so that I can understand slf4j, bridging libraries, logging implementations, etc. My application relies on the slf4j which uses logback for the logging implementation. In addition, it pulls in a library which includes the commons-logging library.
Application dependencies:
dependencies {
compile project(':library-with-jcl')
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
}
Library dependencies:
dependencies {
compile group: 'commons-logging', name: 'commons-logging', version: '1.2'
}
When I do not include jcl-over-slf4j
, then the library will output its logging via JCL, as expected. When I do include jcl-over-slf4j
, then any logging via the JCL logger is picked up by slf4j and redirected to logback.
I keep reading articles all over the internet that say I must exclude the commons-logging
dependency if my application relies on slf4j and a library that depends on JCL. It does not seem to be necessary, however, and I do not understand why. In what situations must I exclude the JCL dependency? Is my example here too simple to expose potential problems?
In addition, I am not seeing suggestions that I must exclude, for example, the log4j dependencies from libraries that depend on it if I am using the log4j bridge. Why not? Is JCL a special case?