/usr/local/tomcat2/webapps/digital/WEB-INF/classes/log4j.properties
log4j.properties配置如下(配置是转载):
log4j.rootLogger=info,Console,R
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
#log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.Console.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy.MM.dd HH:mm:ss} %5p %c{1}(%L):? %m%n
log4j.logger.org.apache=info,R
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG, R
log4j.logger.org.apache.catalina.core=info,R
log4j.logger.org.apache.catalina.session=info,R
这么改完日志信息老全了,就是怕太全了,以后把硬盘空间点没,所以我保留了下旧版的配置信息:
#log4j.rootLogger=info,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.conversionPattern=%5p [%t] - %m%n
#
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=c:/subject.log
log4j.appender.file.MaxFileSize=100KB
log4j.appender.file.MaxBackupIndex=0
log4j.appender.file.layout=org.apache.log4j.SimpleLayout
log4j.appender.file.layout.ConversionPattern=[ssh] %p %t %c - %m%n
#
log4j.logger.com.ibatis=debug,ibatis
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug,ibatis
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug,ibatis
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug,ibatis
#
log4j.logger.java.sql.Connection=debug,ibatis
log4j.logger.java.sql.Statement=debug,ibatis
log4j.logger.java.sql.PreparedStatement=debug,stdout,ibatis
log4j.logger.java.lang.Exception=debug,ibatis
#
log4j.appender.ibatis=org.apache.log4j.RollingFileAppender
log4j.appender.ibatis.File=c:/ibatis.log
log4j.appender.ibatis.MaxFileSize=100KB
log4j.appender.ibatis.MaxBackupIndex=0
log4j.appender.ibatis.layout=org.apache.log4j.SimpleLayout
log4j.appender.ibatis.layout.ConversionPattern=[ssh] %p %t %c - %m%n
log4j.logger.com.opensymphony.xwork2=ERROR
2.将log4j-1.2.15.jar和commons-logging.jar包拷贝到。。。Apache Software Foundation/Tomcat 5.5/common/lib下即可。
做好上面两步,启动服务器的时候,会在tomcat的安装路径下的。。Apache Software Foundation/Tomcat 5.5/logs下自动的
生成tomcat.log文件以记录日志信息。
注:tomcat.log文件中的日志信息会记载很多,如果过大就可能产生磁盘空间不足的问题,建议定时的清除日志信息。