Search code examples
javaloggingoracle10gweblogicopenjpa

Logging JPA SQL with Weblogic 10.3


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?


Solution

  • 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"/>