How to get JDBC binding parameters from Hibernate in JBoss 7?

前端 未结 1 955
北恋
北恋 2021-02-05 18:13

I\'m trying simply to get the values that Hibernate is binding to the queries behind the question marks \"?\" on JBoss 7.

So I\'m editing standalone/configuration/

相关标签:
1条回答
  • 2021-02-05 18:21

    Wow, it's not really like the previous versions... I've finally found the offical way to configure JBoss 7 logging and the logging configuration of Hibernate 4 !

    What you have to do is edit standalone/configuration/standalone.xml (the configuration file of your domain) and search for the <subsystem xmlns="urn:jboss:domain:logging:1.1"> tag.

    Then in the <console-handler name="CONSOLE", I've switched the level information to TRACE (<level name="TRACE") and added the <logger category="org.hibernate">.

    Here is the partial XML :

    <subsystem xmlns="urn:jboss:domain:logging:1.1">
        <console-handler name="CONSOLE" autoflush="true">
            <level name="TRACE"/>
            <formatter>
                <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
            </formatter>
        </console-handler>
        ...
        <logger category="org.hibernate.type.descriptor.sql.BasicBinder">
            <level name="TRACE"/>
        </logger>
        ...
    

    I've found another and better (because it logs all the JDBC method calls, not only basic binding) solution from a blog post: add spy="true" in the <datasource> declaration and TRACE logs from category jboss.jdbc.spy:

    <datasource jta="true" jndi-name="java:jboss/datasources/myDS" pool-name="myPool" enabled="true" use-java-context="true" spy="true" use-ccm="true">
    

    and the logger (in <subsystem xmlns="urn:jboss:domain:logging:1.1">):

    <logger category="jboss.jdbc.spy">
        <level name="TRACE"/>
    </logger>
    
    0 讨论(0)
提交回复
热议问题