2. OpenJPA Logging
Prev | Chapter 3. Logging and Auditing | Next

## 2. OpenJPA Logging

By default, OpenJPA uses a basic logging framework with the following output format:

`millis` `diagnostic context` `level` [`thread name`] `channel` - `message`

For example, when loading an application that uses OpenJPA, a message like the following will be sent to the `openjpa.Runtime` channel:

    2107  INFO   [main] openjpa.Runtime - Starting OpenJPA 2.2.0

The default logging system accepts the following parameters:

- `File`: The name of the file to log to, or `stdout` or `stderr` to send messages to standard out and standard error, respectively. By default, OpenJPA sends log messages to standard error.

- `DefaultLevel`: The default logging level of unconfigured channels. Recognized values are `TRACE, INFO, WARN, ERROR` and `FATAL`. Defaults to `INFO`.

- `DiagnosticContext`: A string that will be prepended to all log messages. If this is not supplied and an `openjpa.Id` property value is available, that value will be used.

- `<channel>`: Using the last token of the logging channel name, you can configure the log level to use for that channel. See the examples below.

Example 3.1. Standard OpenJPA Log Configuration

    <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO"/>

Example 3.2. Standard OpenJPA Log Configuration + All SQL Statements

    <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"/>

Example 3.3. Logging to a File

    <property name="openjpa.Log" value="File=/tmp/org.apache.openjpa.log, DefaultLevel=WARN, Runtime=INFO, Tool=INFO"/>

Prev | Up | Next
Chapter 3. Logging and Auditing | Home | 3. Disabling Logging