来自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>
必须将其放在根元素之前。



