Monday, February 15, 2010

Solving Error - log4j:WARN No appenders could be found for logger

This log4j error is probably the simplest and most common problem ever encountered in Java EE development history.

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 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.layout.ConversionPattern=%-5p %-30.30c{1} %x - %m%n


Christian Schneider said...

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.
For production use the should be at a place on the classpath where you can change it easily.

Anonymous said...

Thank you! very simple and very helpful!

Захари Палазов said...

Thanks a lot, easy and usefull!

saleem said...

thanks... its very helpfull

Charith said...

thanks a lot

ingmmurillo said...

Thank you!!!

Christian said...

+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

CainLara said...

Thank 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 ?

Post a Comment

Copyright 2009 Spring vs Java EE Web Dev. Powered by Blogger Blogger Templates create by Deluxe Templates. WP by Masterplan