Useing Log4J

log4j.rootLogger = DEBUG,CONSOLE, DailyRolling_FILE,ROLLING_FILE

log4j.addivity.org.apache=true
################### 
# Console Appender 
################### 
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender 
log4j.appender.Threshold=INFO 
log4j.appender.CONSOLE.Target=System.out 
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout 
log4j.appender.CONSOLE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n 

log4j.appender.DailyRolling_FILE=org.apache.log4j.DailyRollingFileAppender 
log4j.appender.DailyRolling_FILE.File=D:\\del\\log.log 
log4j.appender.DailyRolling_FILE.Append = true
log4j.appender.DailyRolling_FILE.DatePattern = yyyy-MM-dd'.' 
log4j.appender.DailyRolling_FILE.layout=org.apache.log4j.PatternLayout 
log4j.appender.DailyRolling_FILE.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n


log4j.appender.ROLLING_FILE=org.apache.log4j.RollingFileAppender 
log4j.appender.ROLLING_FILE.Threshold=info,DEBUG,ERROR 
log4j.appender.ROLLING_FILE.File=D:\\del\\Rolling.log 
log4j.appender.ROLLING_FILE.Append=true 
log4j.appender.ROLLING_FILE.MaxFileSize=20MB 
log4j.appender.ROLLING_FILE.MaxBackupIndex=10
log4j.appender.ROLLING_FILE.layout=org.apache.log4j.PatternLayout 
log4j.appender.ROLLING_FILE.layout.ConversionPattern=[framework] %d - %c -%-4r [%t] %-5p %c %x - %m%n



Logger logger=Logger.getLogger(Log.class);

 logger.info("---------------------info"+i);  
 logger.error("---------------------error"+i);
 logger.debug("----debug----"+i);
 

相关推荐