Logging JPA SQL with Weblogic 10.3

2020-03-04 03:10发布

问题:

By looking into the Open JPA website i've found that i can log the generated SQL by using the following:

<property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO"/>

If i try to add the above property to my persistence.xml i get the following warning from weblogic:

<Warning> <J2EE> <BEA-160202> <You have specified a ope
njpa.Log setting in your configuration for persistence unit services.ear#services-ejb.jar#exp#exp. This setting will be ignored, and all log messages
will be sent to the WebLogic logging subsystem. Trace-level logging is controlle
d by the various JPA-specific debug settings in config.xml, or via the WebLogic
console.>

Anyone know what is the option in the console or how i can edit my config.xml to output the SQL?

回答1:

From the OTN Discussion forum here are the steps :

  • Log into the weblogic console
  • Lock and Edit the session
  • Click Environment | Servers
  • Select the server you wish to monitor/debug
  • Click the Debug tab
  • expand the weblogic tree and select the JPA node
  • Click the enable button
  • Activate the changes.

It might depend on the version of WLS you have. I understand that there were some issues if you've downloaded a newer version of OpenJPA and are using it with WLS.

WebLogic issues aside, the configuration string you posted looks a bit off. Did you intend to use something like this (added in SQL=TRACE):

<property name="openjpa.Log" 
                value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"/>


回答2:

For Weblogic 10.3.3, there's some more steps:

  • Log into the weblogic console
  • Lock and Edit the session
  • Click Environment | Servers
  • Select the server you wish to monitor/debug
  • Click the Debug tab, expand the weblogic tree and select the JPA node
  • Click the enable button
  • Activate the changes at the bottom of the page
  • Now click the Logging Tab
  • At the bottom of the page, click Advanced
  • Under Message destination(s) panel, change Severity Level from Standard Out to Debug
  • Save your changes and restart server