| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>2. OpenJPA Logging</title><link rel="stylesheet" href="css/docbook.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.72.0"><link rel="start" href="manual.html" title="Apache OpenJPA User's Guide"><link rel="up" href="ref_guide_logging.html" title="Chapter 3. Logging"><link rel="prev" href="ref_guide_logging.html" title="Chapter 3. Logging"><link rel="next" href="ref_guide_logging_noop.html" title="3. Disabling Logging"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2. |
| OpenJPA Logging |
| </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ref_guide_logging.html">Prev</a> </td><th width="60%" align="center">Chapter 3. |
| Logging |
| </th><td width="20%" align="right"> <a accesskey="n" href="ref_guide_logging_noop.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ref_guide_logging_openjpa"></a>2. |
| OpenJPA Logging |
| </h2></div></div></div><a class="indexterm" name="d0e16844"></a><p> |
| By default, OpenJPA uses a basic logging framework with the following output |
| format: |
| </p><p> |
| <code class="literal">millis</code> <code class="literal">diagnostic context</code> <code class="literal">level</code> [<code class="literal">thread name</code>] <code class="literal">channel</code> - <code class="literal">message</code> |
| </p><p> |
| For example, when loading an application that uses OpenJPA, a message like the |
| following will be sent to the <code class="literal">openjpa.Runtime</code> channel: |
| </p><pre class="programlisting"> |
| 2107 INFO [main] openjpa.Runtime - Starting OpenJPA 0.9.7 |
| </pre><p> |
| The default logging system accepts the following parameters: |
| </p><div class="itemizedlist"><ul type="disc"><li><p> |
| <code class="literal">File</code>: The name of the file to log to, or <code class="literal">stdout |
| </code> or <code class="literal">stderr</code> to send messages to standard out and |
| standard error, respectively. By default, OpenJPA sends log messages to standard |
| error. |
| </p></li><li><p> |
| <code class="literal">DefaultLevel</code>: The default logging level of unconfigured |
| channels. Recognized values are <code class="literal"> TRACE, DEBUG, INFO, WARN,</code> |
| and <code class="literal">ERROR</code>. Defaults to <code class="literal">INFO</code>. |
| </p></li><li><p> |
| <code class="literal">DiagnosticContext</code>: A string that will be prepended to all |
| log messages. If this is not supplied and a <code class="literal">openjpa.Id</code> |
| property value is available, that value will be used. |
| </p></li><li><p> |
| <code class="literal"><channel></code>: Using the last token of the |
| <a href="ref_guide_logging.html#ref_guide_logging_channels" title="1. Logging Channels">logging channel</a> name, you can |
| configure the log level to use for that channel. See the examples below. |
| </p></li></ul></div><div class="example"><a name="ref_guide_logging_openjpa_std_ex"></a><p class="title"><b>Example 3.1. |
| Standard OpenJPA Log Configuration |
| </b></p><div class="example-contents"><pre class="programlisting"> |
| <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO"/> |
| </pre></div></div><br class="example-break"><div class="example"><a name="ref_guide_logging_openjpa_sql_ex"></a><p class="title"><b>Example 3.2. |
| Standard OpenJPA Log Configuration + All SQL Statements |
| </b></p><div class="example-contents"><pre class="programlisting"> |
| <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"/> |
| </pre></div></div><br class="example-break"><div class="example"><a name="ref_guide_logging_openjpa_file"></a><p class="title"><b>Example 3.3. |
| Logging to a File |
| </b></p><div class="example-contents"><pre class="programlisting"> |
| <property name="openjpa.Log" value="File=/tmp/org.apache.openjpa.log, DefaultLevel=WARN, Runtime=INFO, Tool=INFO"/> |
| </pre></div></div><br class="example-break"></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ref_guide_logging.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ref_guide_logging.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ref_guide_logging_noop.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 3. |
| Logging |
| </td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top"> 3. |
| Disabling Logging |
| </td></tr></table></div></body></html> |