views:

1012

answers:

2

How do you enable debug logging for OpenJPA when running an application in WebLogic 11g? I tried the steps given by http://stackoverflow.com/questions/792741/logging-jpa-sql-with-weblogic-10-3, but no OpenJPA log statements appear in the server log. I have also poured over the WebLogic documentation regarding the configuration of logging, but am unclear as to how to enable debug logging for this particular subsystem (JPA). Any ideas?

A: 

Did you try to enable verbose logging using the following property in your persistence.xml file:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="1.0">
    <persistence-unit name="example-logging" transaction-type="RESOURCE_LOCAL">
        <properties>
            <property name="openjpa.Log" value="SQL=TRACE"/>
        </properties>
    </persistence-unit>
</persistence>
Pascal Thivent
Yes, but WebLogic logs this warning when I specify the openjpa.Log property: <Warning> <J2EE> <BEA-160202> <You have specified a openjpa.Log setting in your configuration for persistence unit [my persistence unit]. This setting will be ignored, and all log messages will be sent to the WebLogic logging subsystem. Trace-level logging is controlled by the various JPA-specific debug settings in config.xml, or via the WebLogicconsole.>Even when I enabled debug for the JPA subsystem in the WebLogic console, I still didn't see any JPA-related log messages in the server log
Allen
So you did enable the debug for the JPA subsystem through the console. Can you confirm that you added `SQL=TRACE` to the `openjpa.Log` property? I can't check right now but that would be a strange regression between 10.3 and 10.3.1.
Pascal Thivent
Thanks for the help Pascal...I just fixed the problem and provided an answer.
Allen
+1  A: 

BAH! I just fixed this problem, and its cause is quite frustrating!

When I configured Logging for my server via the WebLogic console ([my domain] -> Environment -> Servers -> [my server] -> Logging tab), I set "Minimum severity to log" at "Trace" and "Severity level" for the server log file to "Debug" (both are options under "Advanced"). Notably, the "Severity level" select box did not provide a "Trace" option. Thus, when I saved the configuration, the server log level was set to Debug. I have since learned that most of Kodo's (and OpenJPA's?) logging is at the Trace level, which is why I couldn't see any JPA logging, even after enabling debug for the JPA subsystem via the "Debug" tab.

The description next to the "Severity level" select box says that "By default all messages go to the log file," so if I hadn't tried to configure logging, I wouldn't have encountered this issue. In order to see Kodo trace logging in the server log, I had to open up my config.xml file (user_projects\domains[my domain]\config\config.xml) and remove the element under .

Consequently, I am baffled as to why the WebLogic console doesn't provide "Trace" as an option for the "Severity level" select boxes under the "Advanced" section of the Logging tab. Is this an oversight, or am I missing a good reason for the omission?

Allen