我想创建2种类型的日志1调试日志,这将创建所有日志,我想要创建活动日志我的意思是每种方法执行多长时间或任何特定信息, 我在log4j属性文件下面使用 - 请纠正我,它只记录一个文件中的所有消息,在java中我已经实例化了两个日志对象,请不要发送任何指针或只是谷歌,因为我已经尝试过去2天所有选项如Google所述, 在此先感谢您的支持,
log4j.rootLogger=debugLog,reportsLog
log4j.appender.debugLog=org.apache.log4j.FileAppender
log4j.appender.debugLog.File=logs/debug.log
log4j.appender.debugLog.layout=org.apache.log4j.PatternLayout
log4j.appender.debugLog.layout.ConversionPattern=%d [%24F:%t:%L] - %m%n
log4j.appender.reportsLog=org.apache.log4j.FileAppender
log4j.appender.reportsLog.File=logs/reports.log
log4j.appender.reportsLog.layout=org.apache.log4j.PatternLayout
log4j.appender.reportsLog.layout.ConversionPattern=%d [%24F:%t:%L] - %m%n
log4j.category.debugLogger=INFO, debugLog
log4j.additivity.debugLogger=false
log4j.category.reportsLogger=DEBUG, reportsLog
log4j.additivity.reportsLogger=false
答案 0 :(得分:1)
log4j.properties 文件下方将配置记录器,将debug
级别的邮件记录到logs/debug.log
文件中。级别为INFO ... FATAL的邮件将记录到logs/reports.log
。
log4j.rootLogger=DEBUG, debugLog, reportsLog
log4j.appender.debugLog=org.apache.log4j.FileAppender
log4j.appender.debugLog.File=logs/debug.log
log4j.appender.debugLog.layout=org.apache.log4j.PatternLayout
log4j.appender.debugLog.layout.ConversionPattern=%d [%24F:%t:%L] - %m%n
log4j.appender.debugLog.filter.f1=org.apache.log4j.varia.LevelRangeFilter
log4j.appender.debugLog.filter.f1.LevelMax=DEBUG
log4j.appender.debugLog.filter.f1.LevelMin=DEBUG
log4j.appender.reportsLog=org.apache.log4j.FileAppender
log4j.appender.reportsLog.File=logs/reports.log
log4j.appender.reportsLog.layout=org.apache.log4j.PatternLayout
log4j.appender.reportsLog.layout.ConversionPattern=%d [%24F:%t:%L] - %m%n
log4j.appender.reportsLog.filter.f1=org.apache.log4j.varia.LevelRangeFilter
log4j.appender.reportsLog.filter.f1.LevelMax=FATAL
log4j.appender.reportsLog.filter.f1.LevelMin=INFO
log4j.category.debugLogger=DEBUG, debugLog
log4j.additivity.debugLogger=false
log4j.category.reportsLogger=INFO, reportsLog
log4j.additivity.reportsLogger=false