log4j 配置和使用

几种不同的包和区别

配置

一个模板

### 设置###
log4j.rootLogger = DEBUG, stdout, E
### 输出信息到控制抬 ###
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.err
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = [%p] %d{yyyy-MM-dd HH:mm:ss} - %c - %m%n
log4j.appender.stdout.Threshold = DEBUG

### 输出到文件
log4j.appender.E = org.apache.log4j.RollingFileAppender
log4j.appender.E.File = log/info.log
log4j.appender.E.Append = true
log4j.appender.E.Threshold = INFO 
log4j.appender.E.MaxFileSize = 10240KB
log4j.appender.E.MaxBackupIndex = 3
log4j.appender.E.layout = org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} [%l:[%p]] %m%n