配置

log4j.rootLogger=INFO,Console,FILELOG 
log4j.logger.com.gwzx=INFO
log4j.logger.org.springframework=INFO,Console
log4j.logger.net.sf.ehcache.store.disk.Segment=INFO
log4j.additivity.org.springframework=false

log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d %p [%c][%L] - <%m>%n


log4j.appender.FILELOG = org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILELOG.File = ${catalina.home}/logs/mall
log4j.appender.FILELOG.DatePattern = '.'yyyy-MM-dd'.log'
log4j.appender.FILELOG.Append = true
log4j.appender.FILELOG.Threshold = INFO
log4j.appender.FILELOG.layout = org.apache.log4j.PatternLayout
log4j.appender.FILELOG.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n

 

 3)修改Tomcat中context.xml文件,在<Context> 标签修改为<Context  swallowOutput="true">,以接管tomcat的日志输出。这样,使用log4j进行日志切分就完成了

参考地址: https://blog.csdn.net/woshiji594167/article/details/80923795

 

posted on 2018-12-03 15:16  1161588342  阅读(116)  评论(0编辑  收藏  举报