commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject cvs commit: jakarta-commons/logging/src/java/org/apache/commons/logging package.html
Date Tue, 04 Dec 2001 04:28:03 GMT
craigmcc    01/12/03 20:28:03

  Added:       logging  .cvsignore PROPOSAL.html
  Migrate the "logging" package from jakarta-commons-sandbox.
  Revision  Changes    Path
  1.1                  jakarta-commons/logging/.cvsignore
  Index: .cvsignore
  1.4       +15 -7     jakarta-commons/logging/PROPOSAL.html
  1.3       +0 -0      jakarta-commons/logging/
  1.3       +2 -3      jakarta-commons/logging/build.xml
  1.6       +23 -2     jakarta-commons/logging/src/java/org/apache/commons/logging/
  1.6       +34 -1     jakarta-commons/logging/src/java/org/apache/commons/logging/
  1.4       +90 -10    jakarta-commons/logging/src/java/org/apache/commons/logging/
  1.6       +6 -1      jakarta-commons/logging/src/java/org/apache/commons/logging/
  1.6       +47 -10    jakarta-commons/logging/src/java/org/apache/commons/logging/
  1.1                  jakarta-commons/logging/src/java/org/apache/commons/logging/package.html
  Index: package.html
  <p>Simple wrapper API around multiple logging APIs.</p>
  <p>This package provides an API for logging in server-based applications that
  can be used around a variety of different logging implementations, including
  prebuilt support for the following:</p>
  <li><a href="">Log4J</a> from Apache's
      Jakarta project.  Each named <a href="Log.html">Log</a> instance is
      connected to a corresponding Log4J Category.</li>
  <li><a href="">
      JDK Logging API</a>, included in JDK 1.4 or later systems.  Each named
      <a href="Log.html">Log</a> instance is connected to a corresponding
      <code>java.util.logging.Logger</code> instance.</li>
  <li><a href="NoOpLog.html">NoOpLog</a> implementation that simply swallows
      all log output, for all named <a href="Log.html">Log</a> isntances.</li>
  <li><a href="SimpleLog.html">SimpleLog</a> implementation that writes
      log output, for all named <a href="Log.html">Log</a> instances, to
  <h3>Configuring the Logging Package APIs</h3>
  <p>The Logging Package APIs are configured based on the values of system
  properties, which are normally set on the command line that started your
  application.  The following system properties are global to all
  <a href="Log.html">Log</a> implementations:
  <li><code>org.apache.commons.logging.log</code> - Fully qualified class
      of the <code>org.apache.commons.logging.Log</code> implementation to be
  <p>If you do not specify the class name of the Log implementation to use, the
  following algorithm is applied:</p>
  <li>If Log4J is available, return an instance of
      <a href="Log4JCategoryLog.html">Log4JCategoryLog</a> that wraps a
      Log4J Category instance of the specified name.</li>
  <li>If the JDK 1.4 logging APIs are available, return an instance
      of <a href="JdkLogger.html">JdkLogger</a> that wraps an instance of
      <code>java.util.logging.Logger</code> for the specified name.</li>
  <li>Return an instance of <a href="NoOpLog.html">NoOpLog</a> that
      throws away all logged output.</li>
  <p>Additionally, each individual <a href="Log.html">Log</a> implementation
  support its own configuration properties.  These will be documented in the
  class descriptions for the corresponding implementation class.</p>
  <p>Finally, some <code>Log</code> implementations (such as the one for
  require an external configuration file for the entire logging environment.
  This file should be prepared in a manner that is specific to the actual logging
  technology being used.</p>
  <h3>Using the Logging Package APIs</h3>
  <p>Use of the Logging Package APIs, from the perspective of an application
  component, consists of the following steps:</p>
  <li>Acquire a reference to an instance of
      <a href="Log.html">org.apache.commons.logging.Log</a>, by calling the
      factory method
      <a href="LogSource.html#makeNewLogInstance(java.lang.String)">
      LogSource.makeNewLogInstance()</a>.  Your application can contain
      references to multiple loggers that are used for different
      purposes.  A typical scenario for a server application is to have each
      major component of the server use its own Log instance.</li>
  <li>Optionally, you can dynamically change the logging detail level by
      calling <a href="Log.html#setLevel(int)">Log.setLevel()</a> with
      an appropriate constant from the <code>Log</code> interface.  Note that,
      in most cases, the underlying logging system configuration will have
      been preconfigured by the system administrator.</li>
  <li>Cause messages to be logged (if the corresponding detail level is enabled)
      by calling appropriate methods (<code>debug()</code>, <code>info()</code>,
      <code>warn()</code>, <code>error</code>, and <code>fatal()</code>).</li>
  <p>For example, you might use the following technique to initialize and
  use a <a href="Log.html">Log</a> instance in an application component:</p>
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogSource;
  public class MyComponent {
    protected Log log = LogSource.makeNewInstance("mycomponent");
    // Called once at startup time
    public void start() {
      ..."MyComponent started");
    // Called once at shutdown time
    public void stop() {
      ..."MyComponent stopped");
    // Called repeatedly to process a particular argument value
    // which you want logged if debugging is enabled
    public void process(String value) {
      // Do the string concatenation only if logging is enabled
      if (log.isDebugEnabled())
        log.debug("MyComponent processing " + value);

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message