Problem with Commons Logging / Log4j setup in spring webapp with tomcat 6?

There are numerous documented instances on the web warning people about the use of commons-logging. So much so, that SLF4J (slf4j.org) is gaining a lot of popularity Considering that you are not interested in using Tomcat with Log4j, you should just use Log4j directly in your application. Particularly if there is no chance that you'll be switching logging frameworks in the future.It'll reduce the complexity of your application, and get rid of any class loader issues you are having with commons-logging This should be a relatively easy search and replace in your text, as commons-logging and log4j both use a similar call structure for their logging methods.

There are numerous documented instances on the web warning people about the use of commons-logging. So much so, that SLF4J (slf4j.org) is gaining a lot of popularity. Considering that you are not interested in using Tomcat with Log4j, you should just use Log4j directly in your application.

Particularly if there is no chance that you'll be switching logging frameworks in the future. It'll reduce the complexity of your application, and get rid of any class loader issues you are having with commons-logging. This should be a relatively easy search and replace in your text, as commons-logging and log4j both use a similar call structure for their logging methods.

1 I think commons-logging (since 1.1, there where bugs resulting in memory leaks before) is ok. But maybe it is the best solution just to use log4j directly - leaving the libraries using commons-logging unlogged. – Arne Burmeister Oct 20 '08 at 15:22 This all worked in Tomcat 5.5 - sometimes things getting worse – Arne Burmeister Oct 20 '08 at 15:31 1 Nope, commons-logging is still garbage (2010), use slf4j.Articles.qos.Ch/thinkAgain.

Html – Crusader Aug 15 '10 at 6:19.

Be especially careful that you have not placed log4j. Jar in the Tomcat commons/lib directory. If the root classloader loads the log4j libraries, you'll run into conflicts and initialization problems when your webapps also try to use log4j.

If you need to use log4j for common Tomcat logging, you'll need to be careful that your webapps do not attempt to load log4j as well. If you have multiple webapps on the server, then you'll need discipline that each webapp's log initialization does not stomp on the initialization of other webapps. Each webapp will need to use unique Logger IDs, which can be accomplished with unique package names.

Using a common log4j in Tomcat with multiple webapps causes serious conflicts when you have shared libraries that all want to do logging, such as The next webapp that attempts to initialize log4j may close the logger of the previous one. It can be a mess.

You need to compile the extra component for full commons-logging. By default Tomcat 6 uses a hardcoded implementation of commons-logging that always delegates to java.util.logging. Building instructions here tomcat.apache.org/tomcat-6.0-doc/buildin... Then replace the tomcat-juli.

Jar in the /bin directory of Tomcat and place the tomcat-juli-adapters. Jar in the /lib directory along with log4j and config.

I do not won't the tomcat itself to log with log4j, just my webapp. Or is there a tomcat classloader bug not allowing to provide my own commons logging? – Arne Burmeister Oct 20 '08 at 13:53 If Tomcat has the Commons Logging classes in it's lib path, then that will be loaded before any JARs in WEB-INF/lib are loaded.

– matt be Oct 20 '08 at 13:56 The problem is the classloader de – Arne Burmeister Oct 20 '08 at 15:23.

If you are using log4j +common logging, you can avoid most of above configurations. Common logging LogFactory have a discovery feature similar to JAXP, in following precedence, searching for Log implementations, 1. Configuration attribute org.apache.commons.loggi" rel="nofollow">org.apache.commons.logging.

Log inside file commons-logging. Properties 2. System property org.apache.commons.loggi" rel="nofollow">org.apache.commons.logging.

Log 3. If the Log4J available at class path, use the corresponding wrapper class (Log4JLogger). 4.

Jdk14Logger 5. SimpleLog just make sure, both common-logging. Jar and common-logging-api.

Jar and log4j. Jar at classpath.

I had similar problem and found a fix now. Start tomcat with additional parameter: org.apache.commons.loggi" rel="nofollow">-Dorg.apache.commons.logging. LogFactory=org.apache.commons.logging.impl.LogFactoryImpl.

May be I am wrong. Please try the following: A) Add appender to my. Package as: OR B) Reduce the log leve of root to INFO.

Its not as easy, I know to config log4j. – Arne Burmeister Feb 18 '10 at 15:19.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions