blob: e3bd76ff774dd98c1df47e2d12513b7a5ea61218 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>2.&nbsp; OpenJPA Logging</title><base href="display"><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="manual.html" title="Apache OpenJPA 3.0 User's Guide"><link rel="up" href="ref_guide_logging.html" title="Chapter&nbsp;3.&nbsp; Logging and Auditing"><link rel="prev" href="ref_guide_logging.html" title="Chapter&nbsp;3.&nbsp; Logging and Auditing"><link rel="next" href="ref_guide_logging_noop.html" title="3.&nbsp; 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.&nbsp;
OpenJPA Logging
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ref_guide_logging.html">Prev</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;3.&nbsp;
Logging and Auditing
</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ref_guide_logging_noop.html">Next</a></td></tr></table><hr></div><div class="section" id="ref_guide_logging_openjpa"><div class="titlepage"><div><div><h2 class="title" style="clear: both">2.&nbsp;
OpenJPA Logging
</h2></div></div></div>
<a class="indexterm" name="d5e9295"></a>
<p>
By default, OpenJPA uses a basic logging framework with the following output
format:
</p>
<p>
<code class="literal">millis</code>&nbsp;&nbsp;<code class="literal">diagnostic context</code>&nbsp;&nbsp;<code class="literal">level</code>&nbsp;&nbsp;[<code class="literal">thread name</code>]&nbsp;&nbsp;<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 2.2.0
</pre>
<p>
The default logging system accepts the following parameters:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
<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 class="listitem">
<p>
<code class="literal">DefaultLevel</code>: The default logging level of unconfigured
channels. Recognized values are <code class="literal">TRACE, INFO, WARN, ERROR </code>
and <code class="literal">FATAL</code>. Defaults to <code class="literal">INFO</code>.
</p>
</li><li class="listitem">
<p>
<code class="literal">DiagnosticContext</code>: A string that will be prepended to all
log messages. If this is not supplied and an <code class="literal">openjpa.Id</code>
property value is available, that value will be used.
</p>
</li><li class="listitem">
<p>
<code class="literal">&lt;channel&gt;</code>: Using the last token of the
<a class="link" href="ref_guide_logging.html#ref_guide_logging_channels" title="1.&nbsp; 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" id="ref_guide_logging_openjpa_std_ex"><p class="title"><b>Example&nbsp;3.1.&nbsp;
Standard OpenJPA Log Configuration
</b></p><div class="example-contents">
<pre class="programlisting">
&lt;property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO"/&gt;
</pre>
</div></div><br class="example-break">
<div class="example" id="ref_guide_logging_openjpa_sql_ex"><p class="title"><b>Example&nbsp;3.2.&nbsp;
Standard OpenJPA Log Configuration + All SQL Statements
</b></p><div class="example-contents">
<pre class="programlisting">
&lt;property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"/&gt;
</pre>
</div></div><br class="example-break">
<div class="example" id="ref_guide_logging_openjpa_file"><p class="title"><b>Example&nbsp;3.3.&nbsp;
Logging to a File
</b></p><div class="example-contents">
<pre class="programlisting">
&lt;property name="openjpa.Log" value="File=/tmp/org.apache.openjpa.log, DefaultLevel=WARN, Runtime=INFO, Tool=INFO"/&gt;
</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>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ref_guide_logging.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ref_guide_logging_noop.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;3.&nbsp;
Logging and Auditing
&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;3.&nbsp;
Disabling Logging
</td></tr></table></div></body></html>