log4j向指定文件输出日志
一.log4j.properties中的配置
log4j.logger.cache=INFO,ERROR,batchFile log4j.addivity.batchFile=false log4j.appender.batchFile = org.apache.log4j.DailyRollingFileAppender log4j.appender.batchFile.File =${catalina.home}/logs/front_batch #log4j.appender.D.File =/eptms/eptms/log/logs/batch/front_batch log4j.appender.batchFile.datePattern = yyyy-MM-dd'.log' log4j.appender.batchFile.Append = true #log4j.appender.D.Threshold = info log4j.appender.batchFile.MaxBackupIndex=90 log4j.appender.batchFile.layout = org.apache.log4j.PatternLayout log4j.appender.batchFile.layout.ConversionPattern =%d{yyyy-MM-dd HH\:mm\:ss} %5p [%c] (%L) - %m%n
二.java代码中的引用
public class TestDemo{ //cache日志 private static Log logger= LogFactory.getLog("cache"); public void test(){ logger.info("记录cache日志"); }
}
由于本人是自己学习总结出来的,有不足之处,请各位看官批评指出,我将及时改正,以提高知识总结的正确性和严谨性,为大家学习提供方便!!!
如若转载,请注明出处!!!