blob: 98e62b4e66e638f9ecb96e0a6e2b1039c5891ddb [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>5.&nbsp; Apache Commons 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&nbsp;3.&nbsp; Logging"><link rel="prev" href="ref_guide_logging_log4j.html" title="4.&nbsp; Log4J"><link rel="next" href="ref_guide_logging_custom.html" title="6.&nbsp; Custom Log"></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
</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ref_guide_logging_custom.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_commons"></a>5.&nbsp;
Apache Commons Logging
</h2></div></div></div><div class="toc"><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></div><a class="indexterm" name="d0e16951"></a><p>
Set the <code class="literal">openjpa.Log</code> property to <code class="literal">commons</code> to
use the <a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://jakarta.apache.org/commons/logging.html" target="_top"> Apache
Jakarta Commons Logging</a> thin library for issuing log messages. The
Commons Logging libraries act as a wrapper around a number of popular logging
APIs, including the
<a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://jakarta.apache.org/log4j/docs/index.html" target="_top"> Jakarta Log4J
</a> project, and the native
<a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://java.sun.com/j2se/1.4/docs/api/java/util/logging/package-summary.html" target="_top">
java.util.logging</a> package in JDK 1.4. If neither of these libraries are
available, then logging will fall back to using simple console logging.
</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" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="ref_guide_logging_jdk14"></a>5.1.&nbsp;
JDK 1.4 java.util.logging
</h3></div></div></div><a class="indexterm" name="d0e16978"></a><p>
When using JDK 1.4 or higher in conjunction with OpenJPA's Commons Logging
support, logging will proceed through Java's built-in logging provided by the
<a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://java.sun.com/j2se/1.4/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 xmlns:xlink="http://www.w3.org/1999/xlink" href="http://java.sun.com/j2se/1.4/docs/guide/util/logging/overview.html" target="_top">
Java Logging Overview</a>.
</p><p>
By default, JDK 1.4'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"><a name="ref_guide_logging_jdk14_propfile"></a><p class="title"><b>Example&nbsp;3.5.&nbsp;
JDK 1.4 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.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_custom.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;
Custom Log
</td></tr></table></div></body></html>