[img]http://dl.iteye.com/upload/picture/pic/57383/5be5c297-8cf5-3ec3-9595-0af13800885b.png[/img]
Logger - 日志写出器,供程序员输出日志信息
Appender - 日志目的地,把格式化好的日志信息输出到指定的地方去
ConsoleAppender - 目的地为控制台的Appender
FileAppender - 目的地为文件的Appender
RollingFileAppender - 目的地为大小受限的文件的Appender
Layout - 日志格式化器,用来把程序员的logging request格式化成字符串
PatternLayout - 用指定的pattern格式化logging request的Layout
Logger的输出方法:
Logger类对象提供一系列方法供程序员输出日志信息:
1 properties 配置
Logger - 日志写出器,供程序员输出日志信息
Appender - 日志目的地,把格式化好的日志信息输出到指定的地方去
ConsoleAppender - 目的地为控制台的Appender
FileAppender - 目的地为文件的Appender
RollingFileAppender - 目的地为大小受限的文件的Appender
Layout - 日志格式化器,用来把程序员的logging request格式化成字符串
PatternLayout - 用指定的pattern格式化logging request的Layout
Logger的输出方法:
Logger类对象提供一系列方法供程序员输出日志信息:
1 public void debug(Object msg);
2 public void debug(Object msg, Throwable t);
3 public void info(Object msg);
4 public void info(Object msg, Throwable t);
5 public void warn(Object msg);
6 public void warn(Object msg, Throwable t);
7 public void error(Object msg);
8 public void error(Object msg, Throwable t);
9 public void fatal(Object msg);
10 public void fatal(Object msg, Throwable t);
1 properties 配置
log4j.rootLogger = DEBUG,stdout,D,E
##,stdout
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{yyyy-MM-dd HH:mm:ss} %5p :%L - %m%n
log4j.appender.stdout.Threshold = error
#D
log4j.appender.D = org.apache.log4j.RollingFileAppender
log4j.appender.D.File = d:/work/logs/javacms/javacms-debug.log
log4j.appender.D.MaxFileSize=1000KB
log4j.appender.D.Append = true
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
log4j.appender.D.Threshold = DEBUG
#E
log4j.appender.E = org.apache.log4j.RollingFileAppender
log4j.appender.E.File = d:/work/logs/javacms/javacms-error.log
log4j.appender.E.Append = true
log4j.appender.E.MaxFileSize=1000KB
log4j.appender.E.layout = org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
log4j.appender.E.Threshold = ERROR