栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用Log4j XML配置文件配置Hibernate日志记录?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用Log4j XML配置文件配置Hibernate日志记录?

来自http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-
configuration.html#configuration-
logging

以下是记录器类别的列表:

Category         Functionorg.hibernate.SQLLog all SQL DML statements as they are executedorg.hibernate.type          Log all JDBC parametersorg.hibernate.tool.hbm2ddl  Log all SQL DDL statements as they are executedorg.hibernate.pretty        Log the state of all entities (max 20 entities) associated with the session at flush timeorg.hibernate.cache         Log all second-level cache activityorg.hibernate.transaction   Log transaction related activityorg.hibernate.jdbc          Log all JDBC resource acquisitionorg.hibernate.hql.ast.AST   Log HQL and SQL ASTs during query parsingorg.hibernate.secure        Log all JAAS authorization requestsorg.hibernate    Log everything (a lot of information, but very useful for troubleshooting)

格式化以粘贴到log4j XML配置文件中:

<!-- Log all SQL DML statements as they are executed --><Logger name="org.hibernate.SQL" level="debug" /><!-- Log all JDBC parameters --><Logger name="org.hibernate.type" level="debug" /><!-- Log all SQL DDL statements as they are executed --><Logger name="org.hibernate.tool.hbm2ddl" level="debug" /><!-- Log the state of all entities (max 20 entities) associated with the session at flush time --><Logger name="org.hibernate.pretty" level="debug" /><!-- Log all second-level cache activity --><Logger name="org.hibernate.cache" level="debug" /><!-- Log transaction related activity --><Logger name="org.hibernate.transaction" level="debug" /><!-- Log all JDBC resource acquisition --><Logger name="org.hibernate.jdbc" level="debug" /><!-- Log HQL and SQL ASTs during query parsing --><Logger name="org.hibernate.hql.ast.AST" level="debug" /><!-- Log all JAAS authorization requests --><Logger name="org.hibernate.secure" level="debug" /><!-- Log everything (a lot of information, but very useful for troubleshooting) --><Logger name="org.hibernate" level="debug" />

注意:大多数记录器使用DEBUG级别,但是org.hibernate.type使用TRACE。在以前的Hibernate版本中,org.hibernate.type也使用DEBUG,但是从Hibernate
3开始,您必须将级别设置为TRACE(或ALL),以便查看JDBC参数绑定日志记录。

并指定了这样的类别:

<logger name="org.hibernate">    <level value="ALL" />    <appender-ref ref="FILE"/></logger>

必须将其放在根元素之前。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/426498.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号