中
我与tomcat一起使用探针。我部署在tomcat 8.5中的应用程序使用log4j进行记录。
这是Log4j.properties
配置:
# Root logger option
log4j.rootLogger=DEBUG, file
log4j.logger.org.hibernate.SQL = DEBUG, file
log4j.logger.org.hibernate.type = TRACE, file
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=${catalina.base}/logs/my-app.log
log4j.appender.file.Append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.appender.file.DatePattern='.'yyyy-MM-dd
log4j.appender.file.rollingPolicy.ActiveFileName=${catalina.base}/logs/my-app.log
log4j.appender.file.rollingPolicy.FileNamePattern=${catalina.base}/logs/archive/my-app-%d{yyyy-MM-dd}.log.gz
一切都很好,我可以罚款日志,但是当服务器重新启动时,我丢失了所有内容。它像探针一样接缝,重新启动后删除日志文件我是否在应用程序上甚至在概率方面都缺少某些内容?
# Root logger option
log4j.rootLogger=DEBUG, stdout, file
# Redirect log messages to console
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{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Redirect log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
#outputs to Tomcat home
log4j.appender.file.File=${catalina.home}/logs/my-app.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
您可以检查上述代码吗?将所有属性放在您的log4j属性文件