1.log4j有三种主要组件:logger、appender and layout | | | | | |
2.Log4j提供的appender有以下几种: | | | | | |
org.apache.log4j.ConsoleAppender(控制台) | | | | | |
org.apache.log4j.FileAppender(文件) | | | | | |
org.apache.log4j.DailyRollingFileAppender(每天产生一个日志文件) | | | |
org.apache.log4j.RollingFileAppender(文件大小到达指定尺寸的时候产生一个新的文件) | | |
org.apache.log4j.WriterAppender(将日志信息以流格式发送到任意指定的地方) | | | |
3.Log4j提供的layout有以下几种: | | | | | |
org.apache.log4j.HTMLLayout(以HTML表格形式布局) | | | | | |
org.apache.log4j.PatternLayout(可以灵活地指定布局模式) | | | | |
org.apache.log4j.SimpleLayout(包含日志信息的级别和信息字符串) | | | | |
org.apache.log4j.TTCCLayout(包含日志产生的时间、线程、类别等等信息) | | | |
4.Log4j提供的几种输出格式: | | | | | |
%M:Used to output the method name where the logging request was issued. | | | |
%m:Used to output the application supplied message associated with the logging event. | |
%l:Used to output location information of the caller which generated the logging event | |
%L:Used to output the line number from where the logging request was issued. | | |
%p:Used to output the priority of the logging event. | | | | | |
%n:Outputs the platform dependent line separator character or characters. 
|
|
相关文章:相关软件: |