Do I use jcl-over-slf4j-1.7.5.jar when I have code that logs using
JCL, but I want it to use SLF4J? Or something else?
You should use the jcl-over-slf4j.jar
if you want to migrate your application from using JCL to SLF4J. Both JCL and SLF4J serves as a simple facade or abstraction for various logging frameworks, for example Log4J. SLF4J is considered a better solution than JCL as it solves various classloading issues related to the the JCL discovery mechanism. Note that the 1.1 release of JCL includes several changes that are intended to resolve those classloading issues.
There are several use cases where you would like to replace JCL with SLF4J:
- Solve class loader issues related to commons logging
- You realized that SLF4J is a better logging facade than JCL
- You would like to use logback which natively implements the SLF4J API
While you can completely replace the use of JCL with SLF4J by replacing the JCL API calls with SLF4J API calls, the JCL over SLF4J implementation will allow you to migrate to SLF4J gradually, especially if some of the libraries your software depends on continue to use JCL (for example the Spring Framework).
When would I use jul-to-slf4j-1.7.5.jar? How is the word "to" here
used differently than "over"?
You should use the jul-to-slf4j-1.7.5.jar
if your application is using java.util.logging
(JUL) as its logging framework and you would like to replace it with SLF4J as a logging facade and have the freedom of choosing between other logging implementations . JUL provides the classes and interfaces of the JavaTM 2 platform's core logging facilities. Contrary to jcl-over-slf4j
, which reimplement JCL, the jul-to-slf4j
module does not reimplement the java.util.logging
because packages under the java.* namespace cannot be replaced. Instead, jul-to-slf4j includes a java.util.logging (jul) handler, namely SLF4JBridgeHandler, which routes all incoming jul records to the SLF4j API. Notice the note SLF4J has about the performance of this solution.
Why is there no "over" JAR for JUL? Why are there no "to" JARs for JCL
and log4j?
As described in previous section, packages under the java.* namespace cannot be replaced and therefore there is no possibility to create a "from" bridging module but rather use a solution which routes JUL API calls to SLF4J. For other bridging modules this overhead is simply not necessary.