
Hello Marten, I read your email again and would like to clarify a few more points about my previous answer... The information I gave you should allow you to configure and use logback as your logging implementation, for your application. I've seen that you put commons-logging-1.1.jar *and* jcl104-over-slf4j-1.1.0-RC1.jar in commons/lib directory. This will probably lead to unexpected behaviour, no matter how it is used. These two jars contains the same classes, up to a certain extent. jcl104-over-slf4j.jar is used to intercept calls to commons-logging and redirect them to a chosen SLF4J implementation. Having both commons-logging-1.1.jar and jcl104-over-slf4j.jar in the same classpath will provide you with two implementations of the same classes: one that redirects to SLF4J and the usual commons-logging implementation. If your application uses logback, but some other application that runs under Tomcat (or any dependency of your application) uses commons-logging, your might use jcl104-over-slf4j.jar to intercept these calls and redirect them to any SLF4J implementation. On the other hand, intercepting Tomcat's own *internal* logging is something that we do not recommand at this time. Sébastien Marten Deinum wrote:
For my current project I would like to switch out all the logging which is currently being done by log4j and here en there by commons-logging to one framework. After some searching I discoverd SLF4J and Logback as the successor to log4j. In your code I swapped out all the log4j and commons-logging to the SLF4J api and I want to use Logback as my logger. I converted our log4j.properties file with the configuration converter on the website, so I assume that is correct.
In the tomcat directory I have the following logging libs (I want tomcat to use SLF4J to) commons/lib/commons-logging-1.1.jar commons/lib/jcl104-over-slf4j-1.1.0-RC1.jar commons/classes/logback.xml
In our webapplication (which is a packaged war and doesn't get unpacked!) I have WEB-INF/lib/slf4j-api-1.1.0-RC1.jar WEB-INF/lib/logback-classic-0.7.jar WEB-INF/lib/logback-core-0.7.jar WEB-INF/classes/logback.xml
The contents of the logback.xml in the commons directory just contains a simple ConsoleAppender and is configured to WARN level.
The file in the WEB-INF directory is configured as a file which should be written to c:\logs\mylog.log, configured different levels for different packages we use.
However logback isn't getting picked up, everything is being logged by the java.util classes (as it appears thatone is being initialized by tomcat instead of the logback logger).
I tried different configurations, all the logback/slf4j jars in the commons/lib and one config file in commons/classes. Different jars in commons/lib and WEB-INF/lib but until now everytime with the same result, only logging to JUL and nothing to logback and my configured logfile.
Currently I'm at a loss on what to do and how to make it work. I need some assistance with this.
Kind Regards, Marten
-- Sébastien Pennec sebastien@qos.ch Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch/