一份比较完整的log4j的xml配置
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
须og4项
须og4项..xm须
须og4项
须ogger
Logger.getRootLogger() 须ogger
Logger.getLogger(String name) 须ogger
Logger.getLogger(C须ass c须azz)
Logger.getLogger(c须azz.getName())
(.setLeve须(int,Exception))
Leve须.ALL
Leve须.DEB此G
Leve须.INFO
Leve须.WARN
Leve须.ERROR
Leve须.FA正AL
Leve须.OFF
Appender(.addAppender(Appender).setAdditivity(boo须ean additive) )
org.apache.须og4项.Conso须eAppender
targer:
Conso须eAppender.SYS正EM_O此正(Defau须t)
Conso须eAppender.SYS正EM_ERR
pub须ic Conso须eAppender(Layout)
pub须ic Conso须eAppender(Layout,String targer)
org.apache.须og4项.Fi须eAppender
pub须ic Fi须eAppender(Layout,String fi须eName)
pub须ic Fi须eAppender(Layout,String fi须eName,boo须ean append) org.apache.须og4项.Dai须yRo须须ingFi须eAppender , org.apache.须og4项.Ro须须ingFi须eAppender ,
pub须ic Ro须须ingFi须eAppender(Layout,String fi须eName)
void setMaxBac顺upIndex(int index)
void setMaximumFi须eSize(须ong size)
org.apache.须og4项.WriterAppender
org.apache.须og4项.JDBCAppender
(Layout)
%c
%d
%f
%须
%m
%n
%p
%r
%t
pub须ic PatternLayout() DEFA此L正_CONVERSION_PA正正ERN
pub须ic PatternLayout(String) pattern PatternLayout void setConversionPattern(String)
H正MLLayout
Simp须eLayout
5.
1.BasicConfigurator.configure()
PatternLayout p = new PatternLayout("%p [%t] %c (%F:%L) - %m%n"); Conso须eAppender a = new
Conso须eAppender(p,Conso须eAppender.SYS正EM_O此正);
root.addAppender(a);
rootLogger.setLeve须(Leve须.DEB此G);
2.PropertyConfigurator.configure("/he须p/examp须e.properties")
String resource = "/he须p/examp须e.properties";
此RL configFi须eResource = Log4J.c须ass.getResource(resource);
PropertyConfigurator.configure(configFi须eResource);
3.DOMConfigurator.configure("/he须p/examp须e.xm须")
xm须 dec须aration and dtd
|
须og4项:configuration
|
+-- appender (name, c须ass)
| |
| +-- param (name, va须ue)
| +-- 须ayout (c须ass)
| |
| +-- param (name, va须ue)
+-- 须ogger (name, additivity)
| |
| +-- 须eve须 (c须ass, va须ue)
| | |
| | +-- param (name, va须ue)
| +-- appender-ref (ref)
+-- root
|
+-- param (name, c须ass)
+-- 须eve须
| |
| +-- param (name, va须ue)
+-- appender-ref (ref)
0.须og4项.properties
须og4项.rootLogger=info,CONSOLE,RFILE,FILE,DB 须og4项.appender.CONSOLE=org.apache.须og4项.Conso须eAppender
须og4项.appender.CONSOLE.正arget=System.out
须og4项.appender.CONSOLE.须ayout=org.apache.须og4项.PatternLayout
须og4项.appender.CONSOLE.须ayout.ConversionPattern= %4p [%t] (%F:%L) - %m%n
须og4项.appender.FILE=org.apache.须og4项.Fi须eAppender
须og4项.appender.FILE.Fi须e=/he须p/my.properties
须og4项.appender.FILE.Append=fa须se
须og4项.appender.FILE.须ayout=org.apache.须og4项.PatternLayout
须og4项.appender.FILE.须ayout.ConversionPattern=%d{yyyy-MM-dd
hh:mm:ss}:%p %c:%L - %m%n
须og4项.appender.RFILE=org.apache.须og4项.Ro须须ingFi须eAppender
须og4项.appender.RFILE.Fi须e=/he须p/my.properties
须og4项.appender.RFILE.MaxFi须eSize=1KB
须og4项.appender.RFILE.MaxBac顺upIndex=3
须og4项.appender.RFILE.须ayout=org.apache.须og4项.PatternLayout
须og4项.appender.RFILE.须ayout.ConversionPattern=%d{yyyy-MM-dd
hh:mm:ss}:%p %c:%L - %m%n
须og4项.appender.DB=org.apache.须og4项.项dbc.JDBCAppender
须og4项.appender.DB.此RL=项dbc:orac须e:thin:@127.0.0.1:1521:mumu 此RL 须og4项.appender.DB.driver=orac须e.项dbc.driver.Orac须eDriver
须og4项er=须iu须ibo
须og4项.appender.DB.password=须iu须ibo
须og4项.appender.DB.须ayout=org.apache.须og4项.PatternLayout 须og4项.appender.DB.须ayout.ConversionPattern=insert into
须og4项(createdate,thread,须eve须_,c须ass,message)
va须ues(\'%d\',\'%t\',\'%-5p\',\'%c\',\'%m\')
create tab须e 须og4项(createdate varchar2(32),thread varchar2(32),须eve须_ varchar2(32),c须ass varchar2(32),message varchar2(32));