Network Deployment (Distributed operating systems), v8.0 > Troubleshoot and support > Troubleshoot EJB applications > Troubleshoot JPA applications


Log applications with JPA

Log 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 you in troubleshooting problems. Log channels

Attention: Logging can have a negative impact on performance. Limit or disable logging when you run any performance tests.

New feature: Beginning in WAS v8.0 you can configure the server to use the High Performance Extensible Logging (HPEL) log and trace infrastructure instead of using SystemOut.log , SystemErr.log, trace.log, and activity.log files or native z/OS logging facilities. If you are using HPEL, you can access all of your log and trace information using the LogViewer command-line tool from your server profile bin directory. See the information about using HPEL to troubleshoot applications for more information on using HPEL.New feature:

In additional to the channels used by OpenJPA, a trace group named openjpa enables channels that are prefixed with “openjpa.” Specifying “openjpa” for a trace group overrides any other trace group specification that is specific to a channel; for example:

openjpa.Runtime=debug:openjpa.jdbc.SQL=all

    openjpa=all

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

OpenJPA and JPA for WAS implement logging channels to which message data, trace data, and debugging data can be recorded to a configurable repository. The JPA component creates the logging channel at run time and assigns a channel name for identification. The component writes information to the configured repository through the channel. OpenJPA and JPA for WAS create the following channels:

Log levels

Each of the logging channels use logging levels to control which messages are recorded. The following logging levels are supported by the JPA architecture:

By using a particular logging channel together with logging levels, you can control the types of logging messages and the amount of logging messages that are recorded.

These logging functions apply only to OpenJPA and JPA for the application server. Logging functions that are provided in implementations of a third-party persistence provider are not covered. However, if the logging output from a third-party persistence provider is directed to the Java or System.err file output streams, the messages are handled by the environment accordingly at run time.

Log in the application server

The default JPA persistence provider that is supported by the application server records messages and tracing data that are automatically integrated into the RAS component. Alternatively, OpenJPA implements a custom logger to route messages from OpenJPA channels to the channels of the application server.

The channel names that are supported by OpenJPA are used as the trace group names in the trace level for the application server. The mappings of OpenJPA logging levels to trace levels in the application server are:

Mapping OpenJPA logging levels to application server trace levels. The mappings of OpenJPA logging levels to trace levels in the application server are:

OpenJPA logging level Trace level for the application server
TRACE debug
INFO info
WARN warning
ERROR error
FATAL fatal

Log in a client container and standalone Java application

OpenJPA logging uses the basic logging framework and output format:

millis [persistence-unit name]level[thread identifier] channel - message 
.

When using IBM Optim PureQuery Run time, the PDQ store manager also uses JDBC in some situations, such as for large result set processing. When tracing all calls to the database, you must trace both JDBC and PDQ.

Example:

property name=”wsjpa.Log” value=”SQL=TRACE”/
This traces the SQL and input parameter values.
property name=”wsjpa.Log” value=”pdq=TRACE, JDBC=TRACE”/
This performs a detailed trace of calls to the IBM Optim PureQuery Runtime and any calls to JDBC. If you are using pureQuery and must trace calls to the database, perform both traces.

The default logging system accepts the following parameters:


Procedure

  1. Open the persistence.xml file for the application to modify.

  2. Add a property name tag to the XML schema named openjpa.log. For example:
    <property name="openjpa.log" .../> 

  3. Add additional parameters. For example:
    <property name="openjpa.log" value="DefaultLevel=WARN .../> 

    To reduce overhead by disabling logging, set the openjpa.log property to NONE and proceed to Step 5.

  4. Designate the logging channels and the logging level. For example:
    <property name="openjpa.log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO" .../> 

  5. Save changes to the file.


Results

The next time the application is started the JPA component logs all channels at the WARN logging level and the Runtime and Tool channels at the INFO level.


What to do next

OpenJPA supports the substitution of other logging methods. Read the logging section of the Apache OpenJPA User Guide for more information and examples.


Related


Enable enhanced tracing for JPA
Enable Enhanced Tracing for JPA in a Java SE environment
Task overview: Storing and retrieving persistent data with the JPA API

+

Search Tips   |   Advanced Search