大家好,只想分享如何配置log4j.properties文件 请注意,#是在行
处注释掉的致命:仅显示致命级别的消息
错误:显示分类为错误和致命的消息
警告:显示分类为警告,错误和致命的消息
INFO:显示分类为INFO,WARNING,ERROR和FATAL的消息
DEBUG:显示分类为DEBUG,INFO,WARNING,ERROR和FATAL的消息
TRACE:显示分类为TRACE,DEBUG,INFO,WARNING,ERROR和FATAL的消息
ALL:显示分类为TRACE,DEBUG,INFO,WARNING,ERROR和FATAL的消息
关闭:不显示日志消息
log4j.rootLogger= INFO, file, console
#Level/rules TRACE < DEBUG < INFO < WARN < ERROR < FATAL.
#######################################
# Direct log messages to a log file
log4j.appender.file.Threshold=ALL
log4j.appender.file.file=logs/myFol.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %c{1} - %m%n
# set file size limit
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=20MB
log4j.appender.file.MaxBackupIndex=50
#############################################
# Direct log messages to System Out
log4j.appender.console.Threshold=INFO
log4j.appender.console.Target=System.out
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
#log4j.appender.console.layout.ConversionPattern=%-5p %L - %m%n
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} - %c{1}: %m%n
#log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %M:%L - %m%n