[log4j] log4j 根据不同的日志级别,将日志写入不同的日志文件

log4j.rootLogger=INFO, Console, infoLog,warnLog

#Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%-5p] %l -> %m%n

#infoLog
log4j.appender.infoLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.infoLog.File=d:/jmw_logs/migration/jmw-migration-info.log
log4j.appender.infoLog.encoding=UTF-8
log4j.appender.infoLog.append=false
log4j.appender.infoLog.Threshold=INFO
#log4j.appender.infoLog.datePattern='.'yyyy-MM-dd'.log'
log4j.appender.infoLog.layout=org.apache.log4j.PatternLayout
log4j.appender.infoLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%-5p] %l -> %m%n

#warnLog
log4j.appender.warnLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.warnLog.File=d:/jmw_logs/migration/jmw-migration-warn.log
log4j.appender.warnLog.encoding=UTF-8
log4j.appender.warnLog.append=false
log4j.appender.warnLog.Threshold=WARN
#log4j.appender.warnLog.datePattern='.'yyyy-MM-dd'.log'
log4j.appender.warnLog.layout=org.apache.log4j.PatternLayout
log4j.appender.warnLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%-5p] %l -> %m%n



你可能感兴趣的:([log4j] log4j 根据不同的日志级别,将日志写入不同的日志文件)