首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

log4j资料日志配置

2012-12-18 
log4j文件日志配置?下面是一段最常见的日志配置模板:#输出到控制条to console#log4j.rootLogger DEBUG,C

log4j文件日志配置

?下面是一段最常见的日志配置模板:

#输出到控制条to console#log4j.rootLogger = DEBUG,Consolelog4j.appender.Console=org.apache.log4j.ConsoleAppenderlog4j.appender.Console.Target=System.outlog4j.appender.Console.layout=org.apache.log4j.PatternLayoutlog4j.appender.Console.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n#输出到文件to file##error/warn/info/debug#log4j.category.com.mylog.admin = debug,outputLoglog4j.appender.outputLog=org.apache.log4j.RollingFileAppenderlog4j.appender.outputLog.Threshold=DEBUGlog4j.appender.outputLog.File=C:/logs/mylog.loglog4j.appender.outputLog.encoding=GB2312log4j.appender.outputLog.layout=org.apache.log4j.PatternLayoutlog4j.appender.outputLog.layout.title=Parser Log#use KB\B\MB\Glog4j.appender.outputLog.MaxFileSize=20MBlog4j.appender.outputLog.Append=truelog4j.appender.outputLog.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n

?

在控制台输出的格式如下:

2011-11-16 18:57:06,018 [com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler]-[DEBUG] Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@1a8739b], property=struts]
2011-11-16 18:57:06,018 [com.opensymphony.xwork2.config.ConfigurationManager]-[DEBUG] Checking ConfigurationProviders for reload.
2011-11-16 18:57:06,018 [org.springframework.orm.hibernate3.SessionFactoryUtils]-[DEBUG] Processing deferred close of Hibernate Sessions
2011-11-16 18:57:06,018 [com.opensymphony.xwork2.config.ConfigurationManager]-[DEBUG] Checking ConfigurationProviders for reload.
2011-11-16 18:57:06,018 [org.springframework.orm.hibernate3.SessionFactoryUtils]-[DEBUG] Processing deferred close of Hibernate Sessions

?

?

生成log文件格式如下:

2011-11-16 18:56:03,554 [org.springframework.jdbc.datasource.DataSourceUtils]-[DEBUG] Returning JDBC Connection to DataSource

热点排行