如何使用log4j,让生成的日志文件以当天日期为名称
1个回答
展开全部
给你个我用的:
log4j.rootCategory=INFO, stdout , R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%t] %C.%M(%L) | %m%n
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=./logs/Server.log
log4j.appender.R.DatePattern = '.'yyyy-MM-dd
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %p [%t] %C.%M(%L) | %m%n
log4j.logger.com.xxx=DEBUG
log4j.logger.controllers=DEBUG
log4j.logger.vo=DEBUG
log4j.logger.notifiers=DEBUG
log4j.logger.com.opensymphony.oscache=WARN
log4j.logger.net.sf.navigator=WARN
log4j.logger.org.apache.commons=WARN
log4j.logger.org.apache.struts=WARN
log4j.logger.org.displaytag=WARN
log4j.logger.org.springframework=WARN
log4j.logger.org.apache.velocity=FATAL
log4j.rootCategory=INFO, stdout , R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%t] %C.%M(%L) | %m%n
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=./logs/Server.log
log4j.appender.R.DatePattern = '.'yyyy-MM-dd
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %p [%t] %C.%M(%L) | %m%n
log4j.logger.com.xxx=DEBUG
log4j.logger.controllers=DEBUG
log4j.logger.vo=DEBUG
log4j.logger.notifiers=DEBUG
log4j.logger.com.opensymphony.oscache=WARN
log4j.logger.net.sf.navigator=WARN
log4j.logger.org.apache.commons=WARN
log4j.logger.org.apache.struts=WARN
log4j.logger.org.displaytag=WARN
log4j.logger.org.springframework=WARN
log4j.logger.org.apache.velocity=FATAL
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询