log4j.xml中配置hibernate输出

在log4j.xml文件中加上,必须在<root>节点前!表示输出hibernate产生所有的信息
    <!-- hibernate -->
    <logger name="org.hibernate">
        <level value="ALL" />
        <appender-ref ref="console"/>
    </logger>
参照表:
Category                    Function

org.hibernate.SQL           Log all SQL DML statements as they are executed
org.hibernate.type          Log all JDBC parameters
org.hibernate.tool.hbm2ddl  Log all SQL DDL statements as they are executed
org.hibernate.pretty        Log the state of all entities (max 20 entities) associated with the session at flush time
org.hibernate.cache         Log all second-level cache activity
org.hibernate.transaction   Log transaction related activity
org.hibernate.jdbc          Log all JDBC resource acquisition
org.hibernate.hql.ast.AST   Log HQL and SQL ASTs during query parsing
org.hibernate.secure        Log all JAAS authorization requests
org.hibernate               Log everything (a lot of information, but very useful for troubleshooting)
需要单独配置某个输出,不使用org.hibernate,eg:
<logger name="org.hibernate.sql" additivity="true">
       <level value="DEBUG"/>
        <appender-ref ref="console"/>
</logger>
表示debug级别输出DML产生的sql语句。参考老外地址http://stackoverflow.com/questions/436276/configuring-hibernate-logging-using-log4j-xml-config-file

你可能感兴趣的:(log4j,Hibernate,log4j.xml)