标签:index actor port factor layout flush back version bbb
log4j.rootLogger=debug,stdout,info,debug,error log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Threshold=DEBUG log4j.appender.stdout.Target=System.err log4j.appender.CONSOLE.ImmediateFlush=true log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%40d{[yyyy-MM-dd HH:mm:ss-S]} [%-5p] [ %-3.3r] [%-10.10c] [%l] [%x] --> %n %m %n log4j.logger.info=info #log4j.additivity.info=false log4j.appender.info=com.sdzw.wgn.MyAppender log4j.appender.info.Threshold = INFO log4j.appender.info.append=true log4j.appender.info.File=/sdzw/ibp/log/project/info.log log4j.appender.info.MaxFileSize=50MB log4j.appender.info.MaxBackupIndex=10 log4j.appender.info.layout=org.apache.log4j.PatternLayout log4j.appender.info.layout.ConversionPattern=%40d{[yyyy-MM-dd HH:mm:ss-S]} [%-5p] [ %-3.3r] [%-10.10c] [%l] [%x] --> %n %m %n log4j.logger.debug=debug log4j.appender.debug=com.sdzw.wgn.MyAppender log4j.appender.debug.Threshold = DEBUG log4j.appender.debug.append=true log4j.appender.debug.File=/sdzw/ibp/log/project/debug.log log4j.appender.debug.MaxFileSize=50MB log4j.appender.debug.MaxBackupIndex=10 log4j.appender.debug.layout=org.apache.log4j.PatternLayout log4j.appender.debug.layout.ConversionPattern=%40d{[yyyy-MM-dd HH:mm:ss-S]} [%-5p] [ %-3.3r] [%-10.10c] [%l] [%x] --> %n %m %n log4j.logger.warn=warn log4j.appender.warn=com.sdzw.wgn.MyAppender log4j.appender.warn.Threshold = DEBUG log4j.appender.warn.append=true log4j.appender.warn.File=/sdzw/ibp/log/project/warn.log log4j.appender.warn.MaxFileSize=50MB log4j.appender.warn.MaxBackupIndex=10 log4j.appender.warn.layout=org.apache.log4j.PatternLayout log4j.appender.warn.layout.ConversionPattern=%40d{[yyyy-MM-dd HH:mm:ss-S]} [%-5p] [ %-3.3r] [%-10.10c] [%l] [%x] --> %n %m %n log4j.logger.error=error log4j.appender.error=com.sdzw.wgn.MyAppender log4j.appender.error.Threshold = ERROR log4j.appender.error.append=true log4j.appender.error.File=/sdzw/ibp/log/project/error.log log4j.appender.error.MaxFileSize=50MB log4j.appender.error.MaxBackupIndex=10 log4j.appender.error.layout=org.apache.log4j.PatternLayout log4j.appender.error.layout.ConversionPattern=%40d{[yyyy-MM-dd HH:mm:ss-S]} [%-5p] [ %-3.3r] [%-10.10c] [%l] [%x] --> %n %m %n
package com.sdzw.wgn; import org.apache.log4j.Priority; import org.apache.log4j.RollingFileAppender; public class MyAppender extends RollingFileAppender { @Override public boolean isAsSevereAsThreshold(Priority priority) { return this.getThreshold().equals(priority); } }
package com.sdzw.wgn; import org.apache.log4j.Logger; import org.slf4j.LoggerFactory; public class TestLog { Logger logger = Logger.getLogger(TestLog.class); Logger logger2 = Logger.getLogger("aaa"); // org.slf4j.Logger logger = LoggerFactory.getLogger(TestLog.class); // org.slf4j.Logger logger2 = LoggerFactory.getLogger("bbb"); private void test1() { logger.debug("debug---"); logger.info("info---"); logger.error("error---"); logger2.debug("debug2---"); logger2.info("info2---"); logger2.error("error2---"); } public static void main(String[] args) { TestLog testLog = new TestLog(); testLog.test1(); } }
log4j配置文件及java调用 每个级别输出到不同的文件2
标签:index actor port factor layout flush back version bbb
原文地址:http://www.cnblogs.com/wangguoning/p/7090515.html