OSCache缓存技术(7)【整合LOG4J】

1.在项目中加入log4j的包

2.在classes中加入log4j.properties

log4j.rootLogger=DEBUG,stdout,file

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[start]%d{yyyy/MM/dd/ HH:mm:ss}[DATE]%n%p[PRIORITY]%n%x[NDC]%n%t[THREAD] n%c[CATEGORY]%n%m[MESSAGE]%n%n

 

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=oscache.log
log4j.appender.file.MaxFileSize=100KB
log4j.appender.file.MaxBackupIndex=5
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[start]%d{yyyy/MM/dd/ HH:mm:ss}[DATE]%n%p[PRIORITY]%n%x[NDC]%n%t[THREAD] n%c[CATEGORY]%n%m[MESSAGE]%n%n


log4j.logger.org.apache.commons=ERROR
log4j.logger.com.opensymphony.oscache.base=INFO

3.修改commons-logging.properties

commons-logging.properties 文件内容为

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JCategoryLog

 

启动服务器,当对缓存进行操作的时候,就会再控制台看到记录信息了!

你可能感兴趣的:(apache,thread,C++,c,log4j)