Log4j配置单独的日志记录器

log4j.rootLogger=info, stdout
#Root Logger
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p(%F:%L)%d{yyyy-MM-dd HH:mm:ss} - %m%n

#============================================================Logger S
log4j.logger.SLog=info, stdout, S
log4j.additivity.SLog = false
log4j.appender.S=org.apache.log4j.RollingFileAppender
log4j.appender.S.File=serarch_s.js
log4j.appender.S.MaxFileSize=10240KB
log4j.appender.S.MaxBackupIndex=1
log4j.appender.S.layout=org.apache.log4j.PatternLayout
log4j.appender.S.layout.ConversionPattern= %d{yyyy-MM-dd HH:mm:ss}- %m%n
#============================================================Logger B
log4j.logger.BLog=DEBUG, stdout, B
log4j.additivity.BLog = false
log4j.appender.B=org.apache.log4j.RollingFileAppender
log4j.appender.B.File=serarch_b.js
log4j.appender.B.MaxFileSize=10240KB
log4j.appender.B.MaxBackupIndex=1
log4j.appender.B.layout=org.apache.log4j.PatternLayout
log4j.appender.B.layout.ConversionPattern= %d{yyyy-MM-dd HH:mm:ss}- %m%n



程序中获取不同的日志记录器..

private static Logger log1 = Logger.getLogger("SLog");
private static Logger log2 = Logger.getLogger("BLog");
.......


你可能感兴趣的:(Log4j配置单独的日志记录器)