如何从JBoss 7中的Hibernate获取JDBC绑定参数? [英] How to get JDBC binding parameters from Hibernate in JBoss 7?
问题描述
我正在尝试获取Hibernate绑定到问号背后的查询的值?在JBoss 7上。
所以我正在编辑 standalone / configuration / logging.properties
为了添加:
logger.org.hibernate = DEBUG
logger.org.hibernate.type = ALL
但是我的控制台,日志文件中什么也没有...我缺少什么?
$ b哇,这不是真的像以前的版本...我终于找到了正式方式配置JBoss 7日志记录和日志配置的Hibernate 4 !你有什么必须做的是编辑 standalone / configuration / standalone.xml
(您的域的配置文件
),并搜索< subsystem xmlns =urn:jboss:domain:logging: 1.1>
标签。
然后在< console-handler name =CONSOLE
,我将级别信息切换到TRACE(< level name =TRACE
),并添加了< logger类别=org.hibernate>
。
这是部分XML:
< pre class =lang-xml prettyprint-override>
< subsystem xmlns =urn:jboss:domain:logging:1.1>
< console-handler name =CONSOLEautoflush =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>
...
找到另一个更好的(因为它记录了所有的JDBC方法调用,不仅基本绑定)解决方案从一篇博文:在<$ c中添加 spy =true
$ c>< datasource> 声明和 TRACE
日志从类别 jboss.jdbc.spy
:
< datasource jta =truejndi-name =java:jboss /数据源/ myDSpool-name =myPoolenabled =trueuse-java-context =truespy =trueuse-ccm =true>
和记录器(在< subsystem xmlns =urn:jboss: domain:logging:1.1>
)
logger category =jboss.jdbc.spy>
< level name =TRACE/>
< / logger>
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/logging.properties
in order to add this :
logger.org.hibernate=DEBUG
logger.org.hibernate.type=ALL
But I get nothing in my console, nor in the log file... what am I missing ?
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>
这篇关于如何从JBoss 7中的Hibernate获取JDBC绑定参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!