blob: b93e7ebf293a8640936e8138859356ecd6756834 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>5.&nbsp; Apache Commons 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_log4j.html" title="4.&nbsp; Log4J"><link rel="next" href="ref_guide_logging_slf4j.html" title="6.&nbsp; SLF4J"></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">5.&nbsp;
Apache Commons Logging
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ref_guide_logging_log4j.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_slf4j.html">Next</a></td></tr></table><hr></div><div class="section" id="ref_guide_logging_commons"><div class="titlepage"><div><div><h2 class="title" style="clear: both">5.&nbsp;
Apache Commons Logging
</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="ref_guide_logging_commons.html#ref_guide_logging_jdk14">5.1.
JDK java.util.logging
</a></span></dt></dl></div>
<a class="indexterm" name="d5e9366"></a>
<p>
Set the <code class="literal">openjpa.Log</code> property to <code class="literal">commons</code> to
use the <a class="ulink" href="http://commons.apache.org/logging/" target="_top"> Apache
Commons Logging</a> thin library for issuing log messages. The
Commons Logging library act as a wrapper around a number of popular logging
APIs, including the
<a class="ulink" href="http://logging.apache.org/log4j/1.2/index.html" target="_top"> Jakarta Log4J
</a> project, and the native
<a class="ulink" href="http://download.oracle.com/javase/6/docs/api/java/util/logging/package-summary.html" target="_top">
java.util.logging</a> package in JDK.
</p>
<p>
When using the Commons Logging framework in conjunction with Log4J,
configuration will be the same as was discussed in the Log4J section above.
</p>
<div class="section" id="ref_guide_logging_jdk14"><div class="titlepage"><div><div><h3 class="title">5.1.&nbsp;
JDK java.util.logging
</h3></div></div></div>
<a class="indexterm" name="d5e9378"></a>
<p>
When using JDK logging in conjunction with OpenJPA's Commons Logging
support, logging will proceed through Java's built-in logging provided by the
<a class="ulink" href="http://download.oracle.com/javase/6/docs/api/java/util/logging/package-summary.html" target="_top">
java.util.logging</a> package. For details on configuring the built-in
logging system, please see the
<a class="ulink" href="http://download.oracle.com/javase/6/docs/technotes/guides/logging/overview.html" target="_top">
Java Logging Overview</a>.
</p>
<p>
By default, JDK's logging package looks in the <code class="filename">
JAVA_HOME/lib/logging.properties</code> file for logging configuration. This
can be overridden with the <code class="literal">java.util.logging.config.file</code>
system property. For example:
</p>
<pre class="programlisting">
java -Djava.util.logging.config.file=mylogging.properties com.company.MyClass
</pre>
<div class="example" id="ref_guide_logging_jdk14_propfile"><p class="title"><b>Example&nbsp;3.5.&nbsp;
JDK Log Properties
</b></p><div class="example-contents">
<pre class="programlisting">
# specify the handlers to create in the root logger
# (all loggers are children of the root logger)
# the following creates two handlers
handlers=java.util.logging.ConsoleHandler, java.util.logging.FileHandler
# set the default logging level for the root logger
.level=ALL
# set the default logging level for new ConsoleHandler instances
java.util.logging.ConsoleHandler.level=INFO
# set the default logging level for new FileHandler instances
java.util.logging.FileHandler.level=ALL
# set the default formatter for new ConsoleHandler instances
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
# set the default logging level for all OpenJPA logs
openjpa.Tool.level=INFO
openjpa.Runtime.level=INFO
openjpa.Remote.level=INFO
openjpa.DataCache.level=INFO
openjpa.MetaData.level=INFO
openjpa.Enhance.level=INFO
openjpa.Query.level=INFO
openjpa.jdbc.SQL.level=INFO
openjpa.jdbc.SQLDiag.level=INFO
openjpa.jdbc.JDBC.level=INFO
openjpa.jdbc.Schema.level=INFO
</pre>
</div></div><br class="example-break">
</div>
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ref_guide_logging_log4j.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_slf4j.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4.&nbsp;
Log4J
&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;6.&nbsp;
SLF4J
</td></tr></table></div></body></html>