Log4j 文件日志

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;

private static Log log = LogFactory.getLog(WapPushMain.class);
PropertyConfigurator.configure(System.getProperty("user.dir")+"/config/wp.properties");

====================================================================
log4j.rootLogger=INFO,InfoFile
log4j.appender.InfoFile=org.apache.log4j.RollingFileAppender
log4j.appender.InfoFile.File=d:/wp.log
log4j.appender.InfoFile.MaxFileSize=2MB
log4j.appender.InfoFile.MaxBackupIndex=10
log4j.appender.InfoFile.Append = true
log4j.appender.InfoFile.Threshold = INFO 
log4j.appender.InfoFile.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoFile.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%p]-[%t]-[%F:%L]: %m%n 
======================================================================

同时配置 控制台输入和文件输入
log4j.rootLogger=INFO,InfoFile,CONSOLE
log4j.appender.InfoFile=org.apache.log4j.RollingFileAppender
log4j.appender.InfoFile.File=d:/developer/Workspace/yxt/application4/config/wp.log
log4j.appender.InfoFile.MaxFileSize=2MB
log4j.appender.InfoFile.MaxBackupIndex=10
log4j.appender.InfoFile.Append = true
log4j.appender.InfoFile.Threshold = INFO 
log4j.appender.InfoFile.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoFile.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%p]-[%t]-[%F:%L]: %m%n

# console
#log4j.rootLogger=INFO,CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender 
log4j.appender.Threshold=DEBUG 
log4j.appender.CONSOLE.Target=System.out 
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout 
log4j.appender.CONSOLE.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%p]-[%t]-[%F:%L]: %m%n

你可能感兴趣的:(apache,log4j,F#)