本文介绍了WebSphere(8.5.5)不记录OpenJPA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对记录SQL语句感兴趣.我尝试了两种方法,用log4j2和写入文件都是徒劳的.

I'm interested in logging SQL statements. I've tried two approaches, with log4j2 and writing to file, both in vain.

我在persistence.xml

<property name="openjpa.Log" value="SQL=TRACE" />
<property name="openjpa.Log" value="File=openjpa_ra.log" />
<property name="openjpa.ConnectionFactoryProperties" value="PrintParameters=true" />

,我希望它可以写入文件,但是什么也没发生.另一方面,当我指定

and I'm expecting it to write to the file, but nothing happened. On the other hand, when I specify

<property name="openjpa.Log" value="log4j" />

尽管已配置了附加程序,但我的log4j2文件中没有任何变化,而不是文件行.

instead of file line, nothing is changes in my log4j2 files, despite having configured appender.

更新:我已经在persistence.xml中配置了以下内容:

Update: I have configured the following in persistence.xml:

            <property name="openjpa.Log" value="File=d:\openra_log.log, DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"/>  

现在已生成文件,但是我看到的行只有

And now the file is produced, but lines I see there are only lines of

INFO   [Worker-370] openjpa.Tool - Enhancer running on type "class type"

推荐答案

安东(Anton),很可能在应用程序服务器中先前加载的组件之一中覆盖了log4j配置.

Anton , chances are the log4j configuration is overridden in one of a previously loaded component in the application server.

弄清楚正在发生的事情的最佳选择是更改服务器端的跟踪级别,专门针对具有正确跟踪级别字符串的开放JPA.

Your best bet to figure out what is happening could be to change the trace levels on the server side specifically for open JPA with the right trace level strings.

您可以导航以更改日志记录详细信息(紧随图像上的碎屑)并为打开的JPA使用跟踪字符串(* = info:openjpa.Query = all:openjpa.jdbc_JDBC = all:openjpa.jdbc_SQL = all).配置更改将需要重新启动服务器.

You can navigate to change logging detail (follow the crumb on the image) and use a trace string for open JPA (*=info: openjpa.Query=all: openjpa.jdbc_JDBC=all: openjpa.jdbc_SQL=all). Changes in configuration will need a reboot of the server.

这篇关于WebSphere(8.5.5)不记录OpenJPA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 14:09