| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>5. Apache Commons Logging</title><link rel="stylesheet" href="css/docbook.css" type="text/css"><base href="display"><meta name="generator" content="DocBook XSL Stylesheets V1.72.0"><link rel="start" href="manual.html" title="Apache OpenJPA 2.1 User's Guide"><link rel="up" href="ref_guide_logging.html" title="Chapter 3. Logging"><link rel="prev" href="ref_guide_logging_log4j.html" title="4. Log4J"><link rel="next" href="ref_guide_logging_slf4j.html" title="6. 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. |
| Apache Commons Logging |
| </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ref_guide_logging_log4j.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_slf4j.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. |
| 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 java.util.logging |
| </a></span></dt></dl></div><a class="indexterm" name="d0e19743"></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://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 xmlns:xlink="http://www.w3.org/1999/xlink" href="http://logging.apache.org/log4j/1.2/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/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" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="ref_guide_logging_jdk14"></a>5.1. |
| JDK java.util.logging |
| </h3></div></div></div><a class="indexterm" name="d0e19770"></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 xmlns:xlink="http://www.w3.org/1999/xlink" href="http://java.sun.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 xmlns:xlink="http://www.w3.org/1999/xlink" href="http://java.sun.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"><a name="ref_guide_logging_jdk14_propfile"></a><p class="title"><b>Example 3.5. |
| 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> </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_slf4j.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4. |
| Log4J |
| </td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top"> 6. |
| SLF4J |
| </td></tr></table></div></body></html> |