Logging allows you to view, trace, and troubleshoot 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.
About this task
Logging channels Attention: Logging can have
a negative impact on performance. Limit or disable logging when you run any
performance tests.
OpenJPA and JPA for WebSphere Application
Server 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 WebSphere Application Server create the following
channels:
- openjpa.Tools - Command line and Ant server tools
- openjpa.MetaData - Meta data information
- openjpa.Enhance - Enhancement and runtime class generation
- openjpa.Runtime - Messages generated during runtime
- openjpa.Query - Query information
- openjpa.DataCache - L2 data cache plugin information
- openjpa.jdbc.JDBC - JDBC connection information
- openjpa.jdbc.SQL- Detailed SQL execution statements and information
Logging 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:
- TRACE - the most detailed option
- INFO - information related to the specific channel
- WARN - warning messages
- ERROR - error condition messages
- FATAL - fatal condition messages
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.
Supported configurations: These logging functions
only apply 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 System.out or System.err output streams,
the messages are handled by the environment accordingly at run time.
sptcfg
Logging
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:
OpenJPA logging level |
Trace level for the application server |
TRACE |
debug |
INFO |
info |
WARN |
warning |
ERROR |
error |
FATAL |
fatal |
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 will override any other trace group specification that is
specific to a channel.
Exampleopenjpa.Runtime=debug:openjpa.jdbc.SQL=all
openjpa=all
Avoid trouble: The “openjpa.Log” property will be 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 you
must use the standard trace specification for the application server.
gotcha
Logging
in a client container and standalone Java application
OpenJPA logging
uses the basic logging framework and output format:
millis diagnostic context level [thread name] channel - message
.
The
default logging system accepts the following parameters:
- File: The name of the file to which the application server will
log information. You can also use standard output stdout or standard
error stderr to send messages. By default, JPA sends log messages
to standard error.
- DefaultLevel: The default logging level for channels that are not
configured. The values can be TRACE, INFO, WARN,
and ERROR. The default setting is INFO.
- DiagnosticContext: A string that will be placed at the beginning
of all log messages. If a DiagnosticContext is not supplied and an openjpa.Id
property is available, the openjpa.Id value is used.
- <channel>: The channel that is being logged.
This parameter can be used to configure the logging level of the channel.