I have a Spring webapp packaged as a WAR file being deployed to Tomcat.
Catalina.out shows
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
gen 29, 2013 11:37:04 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
That’s probably a configuration error in either Spring or Hibernate. But in order to find the cause of listenerStart error I think it’s necessary to enable log4j. Googling around I found that the log4j warning is caused by missing log4j configuration, and that’s certain because I haven’t configured it yet.
How do I configure log4j (where do I put the configuration file and what do I type in) in order to log errors to catalina.out, which is the most reasonable place for development logging?
Create a
log4j.xmlfile like this oneThe basic explanation of this configuration file is
appender: you can define multiple appender, the one I set up for you is calledCONSOLEand is aConsoleAppender, which means it writes on the standard output (in a tomcat environment,catalina.out).layoutis the definition of the layout of your log file, take a look to PatternLayout to understand the meaning of what I wrote and to modify to your needslogger, where you define one or more logger for your application. Here I simply define arootLoggerwith default levelinfoand which is going to use theCONSOLEappender.Place this file wherever in your classpath and you will have your log4j configured. For a full tutorial, you can refer to http://logging.apache.org/log4j/1.2/manual.html
EDIT I read over your question again, I suggest you to add a second logger to log spring stuff like
where you just set the level to the fine grained you desire for Spring message. The full tutorial will explain levels quite clearly, but in short the higher the level the less verbose is going to be your log.