log4j详细的常用配置说明介绍
投稿:whsnow
# All,TRACE,DEBUG,INFO,WARN,ERROR,FITAL,OFF
#全局项目日志配置
log4j.rootLogger=ERROR
#指定的包下所有的日志(只输出项目com包下的日志)
log4j.logger.com=DEBUG,yin,dailly_rolling_file
#指定输出级别不受全局管理
log4j.additivity.com=false
# 输出到控制台
log4j.appender.yin = org.apache.log4j.ConsoleAppender
log4j.appender.yin.layout = org.apache.log4j.PatternLayout
log4j.appender.yin.layout.ConversionPattern = %n%d [%p] [%m] [%c] %M()[%L] %n
# 输出到文件
log4j.appender.file = org.apache.log4j.FileAppender
log4j.appender.file.File = C\:\\logs\\log.log
log4j.appenile.file.Append = true
log4j.appender.file.layout = org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern = %-d{yyyy-MM-dd HH\:mm\:ss,SSS} [%c]-[%p] %m%n
#输出到大小滚动文件(100表示备份文件个数)
log4j.appender.rolling_file = org.apache.log4j.RollingFileAppender
log4j.appender.rolling_file.Threshold = ERROR
log4j.appender.rolling_file.File = C\:\\logs\\log_rolling.log
log4j.appenile.rolling_file.Append = true www.jb51.net
log4j.appenile.rolling_file.MaxFileSize = 10KB
log4j.appenile.rolling_file.MaxBackupIndex = 100
log4j.appender.rolling_file.layout = org.apache.log4j.PatternLayout
log4j.appender.rolling_file.layout.ConversionPattern = %-d{yyyy-MM-dd HH\:mm\:ss,SSS} [%c]-[%p] %m%n
# 输出到按日期滚动文件
log4j.appender.dailly_rolling_file = org.apache.log4j.DailyRollingFileAppender
log4j.appender.dailly_rolling_file.File = C\:\\logs\\log_daily_rolling.log
log4j.appender.dailly_rolling_file.DatePattern = .yyyy-MM-dd
log4j.appender.dailly_rolling_file.layout=org.apache.log4j.PatternLayout
log4j.appender.dailly_rolling_file.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss,SSS} [%c]-[%p] %m%n