+

Search Tips   |   Advanced Search

Logging applications with JPA

Logging supports viewing, tracing, and troubleshooting the runtime behavior of an application. Java Persistence API (JPA) provides a flexible logging system that is integrated with the application server to assist us in troubleshooting problems.

Use logging to help troubleshoot problems.

Logging for EclipseLink

Supported trace strings for container-managed JPA applications

  • JPA=all

    Enables JPA container trace

  • eclipselink=all

    Enables all EclipseLink trace (ie: eclipselink.*=all)

  • EclipseLink specific log categories

    Trace strings specific to EclipseLink (ie: eclipselink.sql=all)

Supported trace strings for application-managed JPA applications:

When we run a JPA application that is application-managed, logging and tracing is controlled by the EclipseLink run time. All JPA tracing and logging must be configured through EclipseLink persistence properties in the persistence.xml file.

Notable logging persistence properties:

  • eclipselink.logging.parameters

    If "true", SQL bind parameters are included in exceptions and logs.

Logging for OpenJPA

Supported trace strings for container-managed JPA applications

  • JPA=all

    Enables JPA container trace

  • OpenJPA=all

    Enables all OpenJPA trace (ie: openjpa.*=all)

  • OpenJPA specific log categories

    Trace strings specific to OpenJPA (ie: openjpa.jdbc.SQL=all)

Supported trace strings for application-managed JPA applications:

When we run a JPA application that is application-managed, logging and tracing is controlled by the OpenJPA run time. All JPA tracing and logging must be configured through OpenJPA persistence properties in the persistence.xml file.

Notable OpenJPA logging persistence properties:

  • openjpa.ConnectionFactoryProperties=PrintParameters=true

    If true, SQL bind parameters are included in exceptions and logs.

  • The openjpa.Log property is ignored if it is defined in a container-managed persistence unit that uses the persistence providers provided with the application server. In this case, use the standard trace specification for the application server.

WSJPA-specific tracing information

Trace channels for WSJPA:

  • wsjpa.pdq

    Trace of all interactions between store manager and PDQ run time

  • wsjpa.Sqlgen

    Diagnostic trace for wsdbgen program


Tasks

In the persistence unit definition in the persistence.xml file, specify the logging level depending on the wanted level of logging details that we want. Specify the eclipselink.logging.level property where the value is the logging level. For the list of logging levels available, refer to the EclipseLink logging wiki page. The following example will turn on all logging that is available.

<persistence-unit name="pu">
        <properties>
           <property name="eclipselink.logging.level" value="ALL"/>
...
        </properties>
</persistence-unit>


Subtopics

  • Task overview: Store and retrieve persistent data with the JPA API