Tuesday, May 8, 2007

Jakarta Commons Logging and SLF4J

As a regular user of Jakarta Commons Logging (JCL) library I was surprised by the fact that there is a class loader problem in version 1.0.4. You can find more information here along with examples. There is also a specific JCL Wiki page about this problem. However, according to actual release notes of version 1.1 this issue seems to be fixed and adapters for various implementations are provided in commons-logging-adapters-1.1.jar (at least this is my understanding). The reason why I haven't been suffering from this issue yet is probably due to the fact that we ship all jar files with each application and does not rely on any server shared libraries.

Related to this fact I found that some people recommend using Simple Logging Fasade for Java (SLF4J) library instead of JCL. They claim it is faster, more robust, simper and does not rely on specific class loader machinery. I haven't tried it myself yet but the part I like most is the parameterized logging message (with performance benefits).

Also I came across one another interesting page by Rod Waldholff (and author of JCL). Specifically the last part where he discusses scenarios where the JCL should be used and where it should NOT be used. I think I will consider his words the next time I use logging library in my new project.

No comments: