快速业务通道

hibernate3学习笔记(三) hibernate日志配置文件log4j.properties - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-20

hibernate3学习笔记(三) hibernate日志配置文件log4j.properties

时间:2011-02-01 csdn博客 one_dollar

hibernate 采用 apach common logging 、并结合 log4j 进行日志输出和控制。前面的简单实例中,之所以要引入log4j.properties,就是对日志输出的配置。

完整的log4j.properties文件如下所示:

1.### direct log messages to stdout ###2.log4j.appender.stdout=org.apache.log4j.ConsoleAppender3.log4j.appender.stdout.Target=System.out4.log4j.appender.stdout.layout=org.apache.log4j.PatternLayout5.log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n6.7.### direct messages to file hibernate.log ###8.#log4j.appender.file=org.apache.log4j.FileAppender9.#log4j.appender.file.File=hibernate.log10.#log4j.appender.file.layout=org.apache.log4j.PatternLayout11.#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n12.13.### set log levels - for more verbose logging change ''info'' to ''debug'' ###14.15.log4j.rootLogger=warn, stdout16.17.#log4j.logger.org.hibernate=info18.log4j.logger.org.hibernate=debug19.20.### log HQL query parser activity21.#log4j.logger.org.hibernate.hql.ast.AST=debug22.23.### log just the SQL24.#log4j.logger.org.hibernate.SQL=debug25.26.### log JDBC bind parameters ###27.log4j.logger.org.hibernate.type=info
28.#log4j.logger.org.hibernate.type=debug29.30.### log schema export/update ###31.log4j.logger.org.hibernate.tool.hbm2ddl=debug32.
33.### log HQL parse trees34.#log4j.logger.org.hibernate.hql=debug
35.36.### log cache activity ###37.#log4j.logger.org.hibernate.cache=debug
38.
39.### log transaction activity40.#log4j.logger.org.hibernate.transaction=debug
41.
42.### log JDBC resource acquisition43.#log4j.logger.org.hibernate.jdbc=debug
44.
45.### enable the following line if you want to track down connection ###46.### leakages when using DriverManagerConnectionProvider ###47.#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace

hibernate3学习笔记(三) hibernate日志配置文件log4j.properties(2)

时间:2011-02-01 csdn博客 one_dollar

将 log4j.logger.org.hibernate=debug 更改成 log4j.logger.org.hibernate=error 时,只输出SQL和错误信息。

如下所示:

Hibernate: select hibernate_sequence.nextval from dualHibernate: insert into CDMA_BTS (CODE, NAME, AREAID, BARNID, TYPE, FACTORY, SPEC, USEBEGINTIME, STAFF, RECORDTIME, PROPERTY, FIXED_CODE, STATE, MAINTENANCE_MODE, NOTE, ZCZT, LOCAL, WHBURDEN, STATIONID, COVERTYPE, CHAINCOUNT, SHOOTCOUNT, MSCID, BSCID, TOWERID, IFSURVEY, NETWORDCODE, RATED, MAXSHOOT, MAINTENANCE, AEGISAGREEMENT, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

如果是 log4j.logger.org.hibernate=debug 则输出:

09:54:06,484  INFO Environment:543 - Hibernate 3.3.1.GA09:54:06,500  INFO Environment:576 - hibernate.properties not found09:54:06,500  INFO Environment:709 - Bytecode provider name : javassist09:54:06,515  INFO Environment:627 - using JDK 1.4 java.sql.Timestamp handling09:54:06,562  INFO Configur

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号