I’ve been developing a simple Spring MVC application as a reporting service. Locally, I’ve been running the application with the maven-tomcat-plugin, using mvn tomcat:run. This works exactly as expected. However, I’m now trying to deploy this service to a server running Tomcat 6. I load the war file into the webapps directory, Tomcat notices it, deploys it, and then complains:
log4j:WARN No appenders could be found for logger
(org.springframework.web.filter.CharacterEncodingFilter).
log4j:WARN Please initialize the log4j system properly.
And, unsurprisingly, no logging for the service works.
This above error message isn’t clear to me, and I wonder if anyone could give me some assistance.
For posterity, I have a very simple log4j.properties file (Which lives in /src/main/resources):
log4j.rootLogger=WARN, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern= %d{HH:mm:ss,SSS} [%t] %-5p %x %C{1} : %m%n
log4j.logger.com.rtr=DEBUG
My current hypothesis is that the tomcat box might not be seeing this property bundle at all, but I’m not sure. I was able to confirm this hypothesis by hot-copying the bundle into WEB-INF/classes, and getting an appropriate result. What is the correct location that is both on the classpath, but not in a strange location?
Any guidance is appreciated.
Maven copies the resource files from
/src/main/resourcesto/WEB-INF/classesduring thecompilephase of the mvn lifecycle. Using the commandmvn war:warwill NOT copy these resources, so you must domvn compile war:warfor the resources to be available to your application.