blob: d49beba421fa6e738c9e3a08068ffa1689bc500b [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter&nbsp;3.&nbsp; 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.html" title="Part&nbsp;3.&nbsp;Reference Guide"><link rel="prev" href="ref_guide_conf_jdbc.html" title="6.&nbsp; OpenJPA JDBC Properties"><link rel="next" href="ref_guide_logging_openjpa.html" title="2.&nbsp; OpenJPA 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">Chapter&nbsp;3.&nbsp;
Logging
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ref_guide_conf_jdbc.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;3.&nbsp;Reference Guide</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ref_guide_logging_openjpa.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en" id="ref_guide_logging"><div class="titlepage"><div><div><h2 class="title"><a name="ref_guide_logging"></a>Chapter&nbsp;3.&nbsp;
Logging
</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="ref_guide_logging.html#ref_guide_logging_channels">1.
Logging Channels
</a></span></dt><dt><span class="section"><a href="ref_guide_logging_openjpa.html">2.
OpenJPA Logging
</a></span></dt><dt><span class="section"><a href="ref_guide_logging_noop.html">3.
Disabling Logging
</a></span></dt><dt><span class="section"><a href="ref_guide_logging_log4j.html">4.
Log4J
</a></span></dt><dt><span class="section"><a href="ref_guide_logging_commons.html">5.
Apache Commons Logging
</a></span></dt><dd><dl><dt><span class="section"><a href="ref_guide_logging_commons.html#ref_guide_logging_jdk14">5.1.
JDK 1.4 java.util.logging
</a></span></dt></dl></dd><dt><span class="section"><a href="ref_guide_logging_custom.html">6.
Custom Log
</a></span></dt></dl></div><a class="indexterm" name="d0e16813"></a><a class="indexterm" name="d0e16816"></a><p>
Logging is an important means of gaining insight into your application's runtime
behavior. OpenJPA provides a flexible logging system that integrates with many
existing runtime systems, such as application servers and servlet runners.
</p><p>
There are four built-in logging plugins: a
<a href="ref_guide_logging_openjpa.html" title="2.&nbsp; OpenJPA Logging">default logging framework</a> that
covers most needs, a <a href="ref_guide_logging_log4j.html" title="4.&nbsp; Log4J"> Log4J</a>
delegate, an <a href="ref_guide_logging_commons.html" title="5.&nbsp; Apache Commons Logging"> Apache Commons Logging
</a> delegate, and a <a href="ref_guide_logging_noop.html" title="3.&nbsp; Disabling Logging">no-op</a>
implementation for disabling logging.
</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>
Logging can have a negative impact on performance. Disable verbose logging (such
as logging of SQL statements) before running any performance tests. It is
advisable to limit or disable logging for a production system. You can disable
logging altogether by setting the <code class="literal">openjpa.Log</code> property to
<code class="literal">none</code>.
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ref_guide_logging_channels"></a>1.&nbsp;
Logging Channels
</h2></div></div></div><a class="indexterm" name="d0e16847"></a><p>
Logging is done over a number of <span class="emphasis"><em>logging channels</em></span>, each of
which has a <span class="emphasis"><em>logging level</em></span> which controls the verbosity of
log messages recorded for the channel. OpenJPA uses the following logging
channels:
</p><div class="itemizedlist"><ul type="disc"><li><p>
<code class="literal">openjpa.Tool</code>: Messages issued by the OpenJPA command line
and Ant tools. Most messages are basic statements detailing which classes or
files the tools are running on. Detailed output is only available via the
logging category the tool belongs to, such as <code class="literal">openjpa.Enhance</code>
for the enhancer (see <a href="ref_guide_pc_enhance.html" title="2.&nbsp; Enhancement">Section&nbsp;2, &#8220;
Enhancement
&#8221;</a>) or <code class="literal">
openjpa.MetaData</code> for the mapping tool (see
<a href="ref_guide_mapping.html#ref_guide_mapping_mappingtool" title="1.&nbsp; Forward Mapping">Section&nbsp;1, &#8220;
Forward Mapping
&#8221;</a>). This logging category
is provided so that you can get a general idea of what a tool is doing without
having to manipulate logging settings that might also affect runtime behavior.
</p></li><li><p>
<a class="indexterm" name="d0e16880"></a>
<code class="literal">openjpa.Enhance</code>: Messages pertaining to enhancement and
runtime class generation.
</p></li><li><p>
<a class="indexterm" name="d0e16892"></a>
<code class="literal">openjpa.MetaData</code>: Details about the generation of metadata
and object-relational mappings.
</p></li><li><p>
<code class="literal">openjpa.Runtime</code>: General OpenJPA runtime messages.
</p></li><li><p>
<a class="indexterm" name="d0e16910"></a>
<code class="literal">openjpa.Query</code>: Messages about queries. Query strings and any
parameter values, if applicable, will be logged to the <code class="literal">TRACE</code>
level at execution time. Information about possible performance concerns will be
logged to the <code class="literal">INFO</code> level.
</p></li><li><p>
<a class="indexterm" name="d0e16928"></a>
<code class="literal">openjpa.DataCache</code>: Messages from the L2 data cache plugins.
</p></li><li><p>
<a class="indexterm" name="d0e16940"></a>
<code class="literal">openjpa.jdbc.JDBC</code>: JDBC connection information. General JDBC
information will be logged to the <code class="literal">TRACE</code> level. Information
about possible performance concerns will be logged to the <code class="literal">INFO
</code> level.
</p></li><li><p>
<a class="indexterm" name="d0e16958"></a>
<code class="literal">openjpa.jdbc.SQL</code>: This is the most common logging channel to
use. Detailed information about the execution of SQL statements will be sent to
the <code class="literal">TRACE</code> level. It is useful to enable this channel if you
are curious about the exact SQL that OpenJPA issues to the datastore.
</p><p>
When using the built-in OpenJPA logging facilities, you can enable SQL logging
by adding <code class="literal">SQL=TRACE</code> to your <code class="literal">openjpa.Log</code>
property.
</p><p>
OpenJPA can optionally reformat the logged SQL to make it easier to read. To
enable pretty-printing, add <code class="literal">PrettyPrint=true</code> to the
<a href="ref_guide_conf_openjpa.html#openjpa.ConnectionFactoryProperties" title="5.14.&nbsp; openjpa.ConnectionFactoryProperties"><code class="literal">
openjpa.ConnectionFactoryProperties</code></a> property. You can control
how many columns wide the pretty-printed SQL will be with the <code class="literal">
PrettyPrintLineLength</code> property. The default line length is 60 columns.
</p><p>
While pretty printing makes things easier to read, it can make output harder to
process with tools like grep.
</p><p>
Pretty-printing properties configuration might look like so:
</p><pre class="programlisting">
&lt;property name="openjpa.Log" value="SQL=TRACE"/&gt;
&lt;property name="openjpa.ConnectionFactoryProperties"
value="PrettyPrint=true, PrettyPrintLineLength=72"/&gt;
</pre></li><li><p>
<a class="indexterm" name="d0e16999"></a>
<code class="literal">openjpa.jdbc.Schema</code>: Details about operations on the
database schema.
</p></li></ul></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ref_guide_conf_jdbc.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ref_guide.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ref_guide_logging_openjpa.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">6.&nbsp;
OpenJPA JDBC Properties
&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;2.&nbsp;
OpenJPA Logging
</td></tr></table></div></body></html>