log4j.properties配置代码:
## loggers definition Level DEBUG INFO WARN ERROR FATALlog4j.rootLogger=DEBUG, stdout, log, errorlog ###Console ### log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target = System.out log4j.appender.stdout.layout = org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern = %d{ABSOLUTE} [ %t ] [ %p ]:%L - %m%n ### Log ### log4j.appender.log = org.apache.log4j.DailyRollingFileAppender log4j.appender.log.File = D:/ERPLog/logs/log.log log4j.appender.log.Append = true log4j.appender.log.Threshold = DEBUG log4j.appender.log.DatePattern='_'yyyy-MM-dd'.log' log4j.appender.log.layout = org.apache.log4j.PatternLayout log4j.appender.log.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} [ %t ] [%p]:%L %m%n ### Error ### log4j.appender.errorlog = org.apache.log4j.DailyRollingFileAppender log4j.appender.errorlog.File = D:/ERPLog/logs/errorLog.loglog4j.appender.errorlog.Append = true log4j.appender.errorlog.Threshold = ERROR log4j.appender.errorlog.DatePattern='_'yyyy-MM-dd'.log' log4j.appender.errorlog.layout = org.apache.log4j.PatternLayout log4j.appender.errorlog.layout.ConversionPattern =%d{yyyy-MM-dd HH:mm:ss} [ %t ] [%p]:%L %m%n
具体讲解参见 http://www.baike.com/wiki/log4j