log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly.Actually it's not even a real problem, but it can be confusing at first. Understandably so because the error message doesn't give any hint over how to "initialize the log4j system properly".
Fortunately, it's very easy. Just save the following code as log4j.properties. Put it inside your classpath root that is WEB-INF/classes. If you're using Maven that would be src/main/resources.
log4j.rootLogger=info, R log4j.appender.R=org.apache.log4j.ConsoleAppender log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%-5p %-30.30c{1} %x - %m%n
For maven I would recommend to save the file to src/test/resources. So it is active in eclipse and for maven tests but does not go into the jar.
ReplyDeleteFor production use the log4j.properties should be at a place on the classpath where you can change it easily.
Thank you! very simple and very helpful!
ReplyDeleteThanks a lot, easy and usefull!
ReplyDeletethanks... its very helpfull
ReplyDeletethanks a lot
ReplyDeleteThank you!!!
ReplyDelete+1 -- I had nighmarish issues trying to figure out why my WS wasn't loading when I included my dao. I got absolutely not output but I knew it was spring-autowired related
ReplyDeleteThank you very much. Quite helpfull. But there is something still which makes me wonder, what about moving to production ? where should it really be located ?
ReplyDelete