NutzCN Logo
问答 log4j配置问题及后台输出信息一小时保存一次
发布于 2950天前 作者 Hamming 1847 次浏览 复制 上一个帖子 下一个帖子
标签:

当前配置如下 我想保存后端所有日志信息一小时生成一次 该如何配置呢

log4j.rootLogger=debug,Console

log4j.logger.org.apache.commons.beanutils=error
log4j.logger.org.quartz.core.QuartzSchedulerThread=info
log4j.logger.org.apache.shiro.web=error
log4j.logger.net.sf.ehcache.statistics=error
log4j.logger.net.sf.ehcache=error
log4j.logger.org.apache.shiro.session=error
log4j.logger.org.apache.shiro.mgt=error
log4j.logger.org.apache.shiro.cache.ehcache=error
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d %l %-5p - %m%n
2 回复
log4j.appender.myAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.myAppender.DatePattern='.'yyyy-MM-dd-HH

我改成酱紫 目测应该没问题

log4j.rootLogger=debug,Console,RollingFile

log4j.logger.org.apache.commons.beanutils=error
log4j.logger.org.quartz.core.QuartzSchedulerThread=info
log4j.logger.org.apache.shiro.web=error
log4j.logger.net.sf.ehcache.statistics=error
log4j.logger.net.sf.ehcache=error
log4j.logger.org.apache.shiro.session=error
log4j.logger.org.apache.shiro.mgt=error
log4j.logger.org.apache.shiro.cache.ehcache=error
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d %l %-5p - %m%n

#每小时生成一个日志文件
log4j.appender.RollingFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.RollingFile.Threshold=Console
log4j.appender.RollingFile.file=../logs/bluejay/log
log4j.appender.RollingFile.DatePattern='_'yyyyMMdd_HH'.txt'
log4j.appender.RollingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.RollingFile.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%l]%m%n
添加回复
请先登陆
回到顶部