In my Spring 4.1 based application, I am not using any web.xml. How can I initialize log4j without web.xml in my app? I came across this SO question which suggests the required configuration through web.xml, but I am not sure how to do it through code.
. I have placed my log4j.properties in WEB-INF/lib folder and it looks like this:
log4j.rootLogger=debug, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
log4j.category.org.springframework.beans.factory=DEBUG
log4j-1.2.17.jar is also in WEB-INF/lib folder. But the following message appears at startup:
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment). log4j:WARN Please initialize the log4j system properly.
Please help.