参考:http://wangjc-opal.javaeye.com/blog/309924[@more@]
log4j.rootLogger=ERROR,system
log4j.appender.system=org.apache.log4j.DailyRollingFileAppender
log4j.appender.system.layout=org.apache.log4j.PatternLayout
log4j.appender.system.File=/weblog/PSNSearch/log/system.log
log4j.appender.system.DatePattern=yyyy-MM-dd'.'
log4j.appender.system.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm,ss} [%p] [%c] %m%n
log4j.appender.search=org.apache.log4j.DailyRollingFileAppender
log4j.appender.search.layout=org.apache.log4j.PatternLayout
log4j.appender.search.File=/weblog/PSNSearch/log/search.log
log4j.appender.search.DatePattern=yyyy-MM-dd'.'
log4j.appender.search.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm,ss} [%p] [%c] %m%n
log4j.additivity.cn.com.company.project.psnsearch.core.impl.LuceneSearchEngineImpl=false
log4j.appender.index=org.apache.log4j.DailyRollingFileAppender
log4j.appender.index.layout=org.apache.log4j.PatternLayout
log4j.appender.index.File=/weblog/PSNSearch/log/index.log
log4j.appender.index.DatePattern=yyyy-MM-dd'.'
log4j.appender.index.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm,ss} [%p] [%c] %m%n
log4j.additivity.cn.com.company.project.psnsearch.core.impl.LuceneIndexGenerator=false
# Print only messages of level DEBUG or above in the package specified
log4j.logger.cn.com.company.project.psnsearch.core.impl.LuceneSearchEngineImpl=DEBUG,search
log4j.logger.cn.com.company.project.psnsearch.core.impl.LuceneIndexGenerator=DEBUG,index
log4j.logger.org=ERROR,system
使用是这个样子的:LogFactory.getLog(PSNSearchAction.class);
也可以自定义输出
log4j.logger.BUSINESS=INFO, A3
log4j.appender.A3.Encoding=UTF-8
log4j.appender.A3=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A3.File =/weblog/PSN/business.log
log4j.appender.A3.layout=org.apache.log4j.PatternLayout
log4j.appender.A3.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %X{UserID} %m %n
log4j.logger.ERROR=ERROR, A5
log4j.appender.A5.Encoding=UTF-8
log4j.appender.A5=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A5.File =/weblog/PSN/error.log
log4j.appender.A5.layout=org.apache.log4j.PatternLayout
log4j.appender.A5.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %X{UserID} %m %n
使用是这个样子的:LogFactory.getLog("BUSINESS"); LogFactory.getLog("ERROR"); 这里的参数就是自定义的