论坛首页 入门技术论坛

简单的log4j.propertier配置

浏览 1589 次
该帖已经被评为新手帖
作者 正文
   发表时间:2010-01-27  

简单的log4j.properties配置,不详细解释了
使用的方式
Logger successLog = Logger.getLogger("switch.success");
Logger failedLog = Logger.getLogger("switch.failed");
适应情况:
只用一个呢,就是简单的Log记录
两个同时用,可以将正确的信息记录在successLog中,异常的信息记录在failedLog中,方便错误的追踪
#---------------------------------------------------------------------
log4j.logger.switch.success=,success.onlineFile,success.onlineConsole
log4j.logger.switch.failed=,failed.onlineFile,failed.onlineConsole


# file appender for success.onlineFile
log4j.appender.success.onlineFile=org.apache.log4j.DailyRollingFileAppender   
log4j.appender.success.onlineFile.file=E:\\switchLog\\success.txt  
log4j.appender.success.onlineFile.DatePattern=.yyyy-MM-dd   
log4j.appender.success.onlineFile.layout=org.apache.log4j.PatternLayout   
log4j.appender.success.onlineFile.layout.ConversionPattern=%m%n

# file appender for success.onlineConsole
log4j.appender.success.onlineConsole.onlineConsole=org.apache.log4j.ConsoleAppender
log4j.appender.success.onlineConsole.onlineConsole.layout=org.apache.log4j.PatternLayout   
log4j.appender.success.onlineConsole.layout.ConversionPattern=%m%n


# file appender for study.onlineFile   
log4j.appender.failed.onlineFile=org.apache.log4j.DailyRollingFileAppender   
log4j.appender.failed.onlineFile.file=E:\\switchLog\\failed.txt  
log4j.appender.failed.onlineFile.DatePattern=.yyyy-MM-dd   
log4j.appender.failed.onlineFile.layout=org.apache.log4j.PatternLayout   
log4j.appender.failed.onlineFile.layout.ConversionPattern=%m%n

# file appender for failed.onlineConsole  
log4j.appender.failed.onlineConsole=org.apache.log4j.ConsoleAppender
log4j.appender.failed.onlineConsole.layout=org.apache.log4j.PatternLayout   
log4j.appender.failed.onlineConsole.layout.ConversionPattern=%m%n
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics