I googled "Spring + log4j", and here is what I get. When running Eclipse + Tomcat, I can see logs in Eclipse console, but I can't find any custom log file in Tomcat. Is there any thing misconfigured in my log4j.properties?
# Root Logger
log4j.rootLogger=DEBUG, stdout, logfile
### direct log messages to stdout ###
log4j.logger.com.ibatis = DEBUG, logfile
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource = DEBUG, logfile
log4j.logger.com.ibatis.common.jdbc.ScriptRunner = DEBUG, logfile
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate = DEBUG, logfile
log4j.logger.java.sql.Connection = DEBUG, logfile
log4j.logger.java.sql.Statement = DEBUG, logfile
log4j.logger.java.sql.PreparedStatement = DEBUG, logfile
log4j.logger.java.sql.ResultSet = DEBUG, logfile
############################## Console Log Configuration ##############################
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# log4j.appender.logfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%5p] - %c -%F(%L) -%m%n
############################## File Log Configuration ##############################
log4j.appender.logfile = org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile.layout.ConversionPattern = %d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.appender.logfile.layout = org.apache.log4j.PatternLayout
log4j.appender.logfile.MaxFileSize = 100K
log4j.appender.logfile.MaxBackupIndex = 100
log4j.appender.logfile.File = ${webApp.root}/logs/swinguserver.log
log4j.appender.logfile.DatePattern = '.'yyyy-MM-dd
# What does Append=true mean?
log4j.appender.logfile.Append=true
${webApp.root} is declared in web.xml:
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webApp.root</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
I thought swinguserver.log would be created in D:\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\logs, but nothing is.
When I change ${webApp.root} to ${catalina.home} as @SachinSarawgi suggested, I can get swinguserver.log under Tomcat 7.0\logs. How could I configure log4j to write log under Tomcat 7.0/webapps/ROOT/logs?
Thank you for any help.