log4j:WARN No appenders could be found for logger in web.xml
If that's the entire log4j.properties file it looks like you're never actually creating a logger. You need a line like:
log4j.rootLogger=debug,A1
I had log4j.properties in the correct place in the classpath and still got this warning with anything that used it directly. Code using log4j through commons-logging seemed to be fine for some reason.
If you have:
log4j.rootLogger=WARN
Change it to:
log4j.rootLogger=WARN, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%5p [%t] (%F:%L) - %m%n
According to http://logging.apache.org/log4j/1.2/manual.html:
The root logger is anonymous but can be accessed with the Logger.getRootLogger() method. There is no default appender attached to root.
What this means is that you need to specify some appender, any appender, to the root logger to get logging to happen.
Adding that console appender to the rootLogger gets this complaint to disappear.
You may get this error when your log4j.properties
are not present in the classpath.
This means you have to move the log4j.properties
into the src folder and set the output to the bin folder so that at run time log4j.properties
will read from the bin folder and your error will be resolved easily.