org.apache.commons.logging.impl

Class AvalonLogger

Implemented Interfaces:
Log

public class AvalonLogger
extends java.lang.Object
implements Log

Implementation of commons-logging Log interface that delegates all logging calls to the Avalon logging abstraction: the Logger interface.

There are two ways in which this class can be used:

Note: AvalonLogger does not implement Serializable because the constructors available for it make this impossible to achieve in all circumstances; there is no way to "reconnect" to an underlying Logger object on deserialization if one was just passed in to the constructor of the original object. This class was marked Serializable in the 1.0.4 release of commons-logging, but this never actually worked (a NullPointerException would be thrown as soon as the deserialized object was used), so removing this marker is not considered to be an incompatible change.

Version:
$Revision: 399221 $ $Date: 2006-05-03 10:20:24 +0100 (Wed, 03 May 2006) $
Author:
Neeme Praks

Field Summary

private static Logger
defaultLogger
Ancesteral avalon logger
private Logger
logger
Avalon logger used to perform log

Constructor Summary

AvalonLogger(Logger logger)
Constructs an AvalonLogger that outputs to the given Logger instance.
AvalonLogger(String name)
Constructs an AvalonLogger that will log to a child of the Logger set by calling setDefaultLogger(Logger).

Method Summary

void
debug(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.debug.
void
debug(Object message, Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.debug.
void
error(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.error.
void
error(Object message, Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.error.
void
fatal(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.fatalError.
void
fatal(Object message, Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.fatalError.
Logger
getLogger()
Gets the Avalon logger implementation used to perform logging.
void
info(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.info.
void
info(Object message, Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.info.
boolean
isDebugEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.debug enabled?
boolean
isErrorEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.error enabled?
boolean
isFatalEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.fatalError enabled?
boolean
isInfoEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.info enabled?
boolean
isTraceEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.debug enabled?
boolean
isWarnEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.warn enabled?
static void
setDefaultLogger(Logger logger)
Sets the ancesteral Avalon logger from which the delegating loggers will descend.
void
trace(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.debug.
void
trace(Object message, Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.debug.
void
warn(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.warn.
void
warn(Object message, Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.warn.

Field Details

defaultLogger

private static Logger defaultLogger
Ancesteral avalon logger

logger

private Logger logger
Avalon logger used to perform log

Constructor Details

AvalonLogger

public AvalonLogger(Logger logger)
Constructs an AvalonLogger that outputs to the given Logger instance.
Parameters:
logger - the avalon logger implementation to delegate to

AvalonLogger

public AvalonLogger(String name)
Parameters:
name - the name of the avalon logger implementation to delegate to

Method Details

debug

public void debug(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.debug.
Specified by:
debug in interface Log
Parameters:
message - to log.

debug

public void debug(Object message,
                  Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.debug.
Specified by:
debug in interface Log
Parameters:
message - to log
t - log this cause

error

public void error(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.error.
Specified by:
error in interface Log
Parameters:
message - to log

error

public void error(Object message,
                  Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.error.
Specified by:
error in interface Log
Parameters:
message - to log
t - log this cause

fatal

public void fatal(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.fatalError.
Specified by:
fatal in interface Log
Parameters:
message - to log

fatal

public void fatal(Object message,
                  Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.fatalError.
Specified by:
fatal in interface Log
Parameters:
message - to log.
t - log this cause.

getLogger

public Logger getLogger()
Gets the Avalon logger implementation used to perform logging.
Returns:
avalon logger implementation

info

public void info(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.info.
Specified by:
info in interface Log
Parameters:
message - to log

info

public void info(Object message,
                 Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.info.
Specified by:
info in interface Log
Parameters:
message - to log
t - log this cause

isDebugEnabled

public boolean isDebugEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.debug enabled?
Specified by:
isDebugEnabled in interface Log

isErrorEnabled

public boolean isErrorEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.error enabled?
Specified by:
isErrorEnabled in interface Log

isFatalEnabled

public boolean isFatalEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.fatalError enabled?
Specified by:
isFatalEnabled in interface Log

isInfoEnabled

public boolean isInfoEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.info enabled?
Specified by:
isInfoEnabled in interface Log

isTraceEnabled

public boolean isTraceEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.debug enabled?
Specified by:
isTraceEnabled in interface Log

isWarnEnabled

public boolean isWarnEnabled()
Is logging to org.apache.avalon.framework.logger.Logger.warn enabled?
Specified by:
isWarnEnabled in interface Log

setDefaultLogger

public static void setDefaultLogger(Logger logger)
Sets the ancesteral Avalon logger from which the delegating loggers will descend.
Parameters:
logger - the default avalon logger, in case there is no logger instance supplied in constructor

trace

public void trace(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.debug.
Specified by:
trace in interface Log
Parameters:
message - to log

trace

public void trace(Object message,
                  Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.debug.
Specified by:
trace in interface Log
Parameters:
message - to log.
t - log this cause.

warn

public void warn(Object message)
Logs a message with org.apache.avalon.framework.logger.Logger.warn.
Specified by:
warn in interface Log
Parameters:
message - to log

warn

public void warn(Object message,
                 Throwable t)
Logs a message with org.apache.avalon.framework.logger.Logger.warn.
Specified by:
warn in interface Log
Parameters:
message - to log
t - log this cause

Copyright 2002-2004 The Apache Software Foundation.