Linux tomcat下catalina.out日志文件分割
前言:
tomcat默认使用Java.util.logging记录日志,默认只记录tomcat的日志,不记录应用的日志。tomcat支持采用log4j进行日志记录,配置方法如下:
1.更新最新的tomcat_juli.jar包到./bin/目录下;
2.拷贝log4j.jar,lo4j.properties到./lib目录下;
3.删除./conf/logging.properties
4.重启
log4j配置样本
实例代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
log4j.rootLogger=INFO,CATALINA log4j.logger.com.danga.MemCached.MemCachedClient=WARN,CATALINA #log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender #log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout #log4j.appender.CONSOLE.encoding = UTF-8 #log4j.appender.CONSOLE.layout.conversionPattern =[%p-%d{yyyy/MM/dd/HH\:mm\:ss}]%c{1}.(%L) - %m%n # Define CATALINA appenders log4j.appender.CATALINA = org.apache.log4j.DailyRollingFileAppender log4j.appender.CATALINA.file = ${catalina.base}/logs/catalina.out log4j.appender.CATALINA.DatePattern ='.'yyyy-MM-dd log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout log4j.appender.CATALINA.layout.conversionPattern = [%p-%d{yyyy/MM/dd/HH\:mm\:ss}]%c{1}.(%L) - %m%n log4j.appender.CATALINA.append = true |
lo4j自动在午夜切割catalina.out成catalina.out.2011-03-07
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!