Take the 2-minute tour ×

I need to decide on a logging framework for a new web application running in containers (Tomcat, JBoss...). This application references java libraries using different logging frameworks.

My reading indicates that some logging frameworks do not work well in container because of classloader issues. I am also reading that this is not an issue anymore. The situation is confusing. What is the status?

It seems like using SLF4J and redirecting to Log4J + using bridges to SLF4J for referenced Java libraries (when necessary) is the safe solution.

Which logging framework should I use for my web application and remain on the safe side?

share|improve this question
Can you use the logging framework which comes with the container or the logging framework which come with Java? –  Peter Lawrey Oct 16 '12 at 11:24
The application can be deployed in different containers. Otherwise, I have no restrictions except those mentioned in the question. –  JVerstry Oct 16 '12 at 11:39
Given your requirements I would use SLF4J but I have only used Apache Karaf lately. ;) –  Peter Lawrey Oct 16 '12 at 11:41
add comment

2 Answers

up vote 1 down vote accepted

After digging the subject deeper, I can conclude the following:

  1. The classloader issues are mostly reported around the Jakarta Common Logging (JCL) interface.
  2. In order to tackle the multiple logging frameworks used in different Java libraries, a logging interface such as SLF4J or JCL is necessary.
  3. SLF4J is a safe solution for web applications running in containers. It is preferable to accessing the logger provided by the container regarding portability issues.

I have summarized my findings in a blog post.

share|improve this answer
Sounds about right. One caveat is that some libraries may be using JBoss Logging, which is yet another logging facade - Hibernate 4 is a notable example. JBoss Logging tries to autodetect a logging provider; if you are using log4j or Logback, it will find and use those. However, if you are using SLF4J and some other provider (eg Gossip, AVSL), then JBoss Logging won't find it, and will use java.util.logging. –  Tom Anderson Oct 16 '12 at 18:34
add comment

You can (and should) deploy your own logging libraries with your web application. There is no guarantee what logging system will be supported on a server, nor how it will be configured. By providing your own, you can tailor it to your applications needs.

So unless you get to specify and manage the application server, ship what you want to use with your application.

share|improve this answer
add comment

Your Answer


