log4j详细的常用配置说明介绍
程序员文章站
2023-11-29 22:53:28
很多屌丝都觉得log4j不好用,因为它不输出到ide的控制台,哈哈,其实都是配置惹的祸,下面看我怎么一步步配置到控制台的,log4j的输出级别和输出模式相信屌丝们都知道的,...
很多屌丝都觉得log4j不好用,因为它不输出到ide的控制台,哈哈,其实都是配置惹的祸,下面看我怎么一步步配置到控制台的,log4j的输出级别和输出模式相信屌丝们都知道的,这里不多说了,直接看代码注释:
# 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
# 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