log4j配置示例

log4j.rootLogger=DEBUG

#将技术网log记录到TNetLog,allLog,errAllLog中
log4j.logger.TNet=DEBUG,console,TNet,allLog,errAllLog

#将局平台相关log记录到abrsLog,allLog,errAllLog中
log4j.logger.abrs=DEBUG,console,abrs,allLog,errAllLog

#将实时秒数据和分钟数据信息记录到timeLog中
log4j.logger.Time=DEBUG,console,inTime

#将接口应用所有信息记录到allLog中
log4j.logger.all=DEBUG,console,allLog

#console--打印到屏幕上
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] [%c][line:%L] - %m%n

#TNet--打印到文件TNet中--专门为TNet服务
log4j.appender.TNet=org.apache.log4j.DailyRollingFileAppender
log4j.appender.TNet.file=./log/TNetLog
log4j.appender.TNet.DatePattern='.'yyyy-MM-dd
log4j.appender.TNet.layout=org.apache.log4j.PatternLayout
log4j.appender.TNet.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [method]:%l%n %m%n

#ABRS--打印到文件abrs中--专门为abrs服务
log4j.appender.abrs=org.apache.log4j.DailyRollingFileAppender
log4j.appender.abrs.file=./log/abrsLog
log4j.appender.abrs.DatePattern='.'yyyy-MM-dd
log4j.appender.abrs.layout=org.apache.log4j.PatternLayout
log4j.appender.abrs.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [method]:%l%n %m%n

#allLog--打印到文件allLog中--记录所有log信息
log4j.appender.allLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.allLog.file=./log/alllog
log4j.appender.allLog.DatePattern='.'yyyy-MM-dd
log4j.appender.allLog.layout=org.apache.log4j.PatternLayout
log4j.appender.allLog.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [method]:%l%n %m%n

#inTime--打印到文件timeLog中--专门为实时分钟数据、秒数据服务
log4j.appender.inTime=org.apache.log4j.RollingFileAppender
log4j.appender.inTime.file=./inTime/timeLog
log4j.appender.inTime.MaxFileSize=2048KB
log4j.appender.inTime.MaxBackupIndex=200
log4j.appender.inTime.layout=org.apache.log4j.PatternLayout
log4j.appender.inTime.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [method]:%l%n %m%n

#--错误信息打印到文件

#A4--打印到文件ErrLog中--记录所有Error Log信息
log4j.appender.errAllLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.errAllLog.file=./log/ErrLog
log4j.appender.errAllLog.DatePattern='.'yyyy-MM-dd
#只输出ERROR级别以上的日志!!!
log4j.appender.errAllLog.Threshold=ERROR
log4j.appender.errAllLog.layout=org.apache.log4j.PatternLayout
log4j.appender.errAllLog.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [method]:%l%n %m%n

你可能感兴趣的:(apache,log4j)