1

On Tomcat 7, I am trying to get logging output from the Spring libraries I am using.

In Tomcat's logging.properties I have:

.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

java.util.logging.ConsoleHandler.level = ALL
1catalina.org.apache.juli.FileHandler.level = ALL

#this does not change the logging level...
org.springframework.level = ALL

# this does change the logging level...
javax.faces.level = ALL
com.sun.faces.level = ALL

As you can see, I now do get logging messages from JSF, but no logging messages from Spring.

Why is that and what am I missing here?

UPDATE:

I have noticed that when I remove log4j.jar from the classpath, I do get logging from Spring. But when I add log4j.jar to the classpath, the logging from Spring is gone. Can you explain why?

BTW I do need log4j in my classpath, since one of the other jars I am using, refers to log4j explicitly in its code.

rapt
  • 11,810
  • 35
  • 103
  • 145

1 Answers1

1

I would use slf4j logging separate from Tomcat logging. Use application logging not container logging.

References:

http://blog.springsource.org/2009/12/04/logging-dependencies-in-spring/ How do I configure Spring and SLF4J so that I can get logging?

Example application: https://src.springframework.org/svn/spring-samples/mvc-basic/trunk/

Community
  • 1
  • 1
chrislovecnm
  • 2,549
  • 3
  • 20
  • 36
  • you have two different log4j's probably colliding. Again I recommend using slf4j and app level logging – chrislovecnm Apr 08 '12 at 23:37
  • I've read the link you provided. They are not clear there why using commons-logging (JCL) should be a problem that might prevent logging. But from the link it seems like I should have in my classpath either JCL or SLF4J, not both (?). Well, **I cannot remove log4j or JCL**, because some of the jars I use refer to them explicitly. Is there still a way I can get Spring's logging messages on Tomcat? – rapt Apr 09 '12 at 00:16
  • Look at the example that I sent you. I would recommend that you setup the application logging in the same manner. – chrislovecnm Apr 09 '12 at 02:09