org.apache.commons.logging.impl
Class DefaultLog4JLogger

java.lang.Object
  extended by org.apache.commons.logging.impl.DefaultLog4JLogger
All Implemented Interfaces:
java.io.Serializable, Log

public class DefaultLog4JLogger
extends java.lang.Object
implements Log, java.io.Serializable

Implementation of Log that maps directly to a Log4J Logger. Initial configuration of the corresponding Logger instances should be done in the usual manner, as outlined in the Log4J documentation.

Version:
$Id: DefaultLog4JLogger.java,v 1.1 2006/04/19 02:42:50 starksm Exp $
Author:
Scott Sanders, Rod Waldhoff, Robert Burrell Donkin, Scott.Stark@jboss.org
See Also:
Serialized Form

Field Summary
private static java.lang.String FQCN
          The fully qualified name of the Log4JLogger class.
private static boolean is12
           
private  org.apache.log4j.Logger logger
          Log to this logger
private  java.lang.String name
          Logger name
private  org.apache.log4j.Level TRACE
           
 
Constructor Summary
DefaultLog4JLogger()
           
DefaultLog4JLogger(org.apache.log4j.Logger logger)
          For use with a log4j factory.
DefaultLog4JLogger(java.lang.String name)
          Base constructor.
 
Method Summary
 void debug(java.lang.Object message)
          Log a message to the Log4j Logger with DEBUG priority.
 void debug(java.lang.Object message, java.lang.Throwable t)
          Log an error to the Log4j Logger with DEBUG priority.
 void error(java.lang.Object message)
          Log a message to the Log4j Logger with ERROR priority.
 void error(java.lang.Object message, java.lang.Throwable t)
          Log an error to the Log4j Logger with ERROR priority.
 void fatal(java.lang.Object message)
          Log a message to the Log4j Logger with FATAL priority.
 void fatal(java.lang.Object message, java.lang.Throwable t)
          Log an error to the Log4j Logger with FATAL priority.
 org.apache.log4j.Logger getLogger()
          Return the native Logger instance we are using.
private  org.apache.log4j.Level getTrace()
           
 void info(java.lang.Object message)
          Log a message to the Log4j Logger with INFO priority.
 void info(java.lang.Object message, java.lang.Throwable t)
          Log an error to the Log4j Logger with INFO priority.
 boolean isDebugEnabled()
          Check whether the Log4j Logger used is enabled for DEBUG priority.
 boolean isErrorEnabled()
          Check whether the Log4j Logger used is enabled for ERROR priority.
 boolean isFatalEnabled()
          Check whether the Log4j Logger used is enabled for FATAL priority.
 boolean isInfoEnabled()
          Check whether the Log4j Logger used is enabled for INFO priority.
 boolean isTraceEnabled()
          Check whether the Log4j Logger used is enabled for TRACE priority.
 boolean isWarnEnabled()
          Check whether the Log4j Logger used is enabled for WARN priority.
 void trace(java.lang.Object message)
          Log a message to the Log4j Logger with TRACE priority.
 void trace(java.lang.Object message, java.lang.Throwable t)
          Log an error to the Log4j Logger with TRACE priority.
 void warn(java.lang.Object message)
          Log a message to the Log4j Logger with WARN priority.
 void warn(java.lang.Object message, java.lang.Throwable t)
          Log an error to the Log4j Logger with WARN priority.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FQCN

private static final java.lang.String FQCN
The fully qualified name of the Log4JLogger class.


is12

private static final boolean is12

TRACE

private org.apache.log4j.Level TRACE

logger

private transient org.apache.log4j.Logger logger
Log to this logger


name

private java.lang.String name
Logger name

Constructor Detail

DefaultLog4JLogger

public DefaultLog4JLogger()

DefaultLog4JLogger

public DefaultLog4JLogger(java.lang.String name)
Base constructor.


DefaultLog4JLogger

public DefaultLog4JLogger(org.apache.log4j.Logger logger)
For use with a log4j factory.

Method Detail

getTrace

private org.apache.log4j.Level getTrace()

trace

public void trace(java.lang.Object message)
Log a message to the Log4j Logger with TRACE priority. Currently logs to DEBUG level in Log4J.

Specified by:
trace in interface Log
Parameters:
message - log this message

trace

public void trace(java.lang.Object message,
                  java.lang.Throwable t)
Log an error to the Log4j Logger with TRACE priority. Currently logs to DEBUG level in Log4J.

Specified by:
trace in interface Log
Parameters:
message - log this message
t - log this cause

debug

public void debug(java.lang.Object message)
Log a message to the Log4j Logger with DEBUG priority.

Specified by:
debug in interface Log
Parameters:
message - log this message

debug

public void debug(java.lang.Object message,
                  java.lang.Throwable t)
Log an error to the Log4j Logger with DEBUG priority.

Specified by:
debug in interface Log
Parameters:
message - log this message
t - log this cause

info

public void info(java.lang.Object message)
Log a message to the Log4j Logger with INFO priority.

Specified by:
info in interface Log
Parameters:
message - log this message

info

public void info(java.lang.Object message,
                 java.lang.Throwable t)
Log an error to the Log4j Logger with INFO priority.

Specified by:
info in interface Log
Parameters:
message - log this message
t - log this cause

warn

public void warn(java.lang.Object message)
Log a message to the Log4j Logger with WARN priority.

Specified by:
warn in interface Log
Parameters:
message - log this message

warn

public void warn(java.lang.Object message,
                 java.lang.Throwable t)
Log an error to the Log4j Logger with WARN priority.

Specified by:
warn in interface Log
Parameters:
message - log this message
t - log this cause

error

public void error(java.lang.Object message)
Log a message to the Log4j Logger with ERROR priority.

Specified by:
error in interface Log
Parameters:
message - log this message

error

public void error(java.lang.Object message,
                  java.lang.Throwable t)
Log an error to the Log4j Logger with ERROR priority.

Specified by:
error in interface Log
Parameters:
message - log this message
t - log this cause

fatal

public void fatal(java.lang.Object message)
Log a message to the Log4j Logger with FATAL priority.

Specified by:
fatal in interface Log
Parameters:
message - log this message

fatal

public void fatal(java.lang.Object message,
                  java.lang.Throwable t)
Log an error to the Log4j Logger with FATAL priority.

Specified by:
fatal in interface Log
Parameters:
message - log this message
t - log this cause

getLogger

public org.apache.log4j.Logger getLogger()
Return the native Logger instance we are using.


isDebugEnabled

public boolean isDebugEnabled()
Check whether the Log4j Logger used is enabled for DEBUG priority.

Specified by:
isDebugEnabled in interface Log
Returns:
true if debug is enabled in the underlying logger.

isErrorEnabled

public boolean isErrorEnabled()
Check whether the Log4j Logger used is enabled for ERROR priority.

Specified by:
isErrorEnabled in interface Log
Returns:
true if error is enabled in the underlying logger.

isFatalEnabled

public boolean isFatalEnabled()
Check whether the Log4j Logger used is enabled for FATAL priority.

Specified by:
isFatalEnabled in interface Log
Returns:
true if fatal is enabled in the underlying logger.

isInfoEnabled

public boolean isInfoEnabled()
Check whether the Log4j Logger used is enabled for INFO priority.

Specified by:
isInfoEnabled in interface Log
Returns:
true if info is enabled in the underlying logger.

isTraceEnabled

public boolean isTraceEnabled()
Check whether the Log4j Logger used is enabled for TRACE priority. For Log4J, this returns the value of isEnabledFor(TRACE)

Specified by:
isTraceEnabled in interface Log
Returns:
true if trace is enabled in the underlying logger.

isWarnEnabled

public boolean isWarnEnabled()
Check whether the Log4j Logger used is enabled for WARN priority.

Specified by:
isWarnEnabled in interface Log
Returns:
true if warn is enabled in the underlying logger.


Copyright 2001-2005 The Apache Software Foundation.