Package org.apache.commons.logging.impl
Class AvalonLogger
java.lang.Object
org.apache.commons.logging.impl.AvalonLogger
- All Implemented Interfaces:
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:
- the instance can be constructed with an Avalon logger
(by calling
AvalonLogger(Logger)). In this case, it acts as a simple thin wrapping implementation over the logger. This is particularly useful when using a property setter. - the
setDefaultLogger(org.apache.avalon.framework.logger.Logger)class property can be called which sets the ancestral Avalon logger for this class. AnyAvalonLoggerinstances created through theLogFactorymechanisms will output to child loggers of thisLogger.
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:
- $Id: AvalonLogger.java 1435115 2013-01-18 12:40:19Z tn $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static org.apache.avalon.framework.logger.LoggerAncestral Avalon logger.private final org.apache.avalon.framework.logger.LoggerAvalon logger used to perform log. -
Constructor Summary
ConstructorsConstructorDescriptionAvalonLogger(String name) Constructs anAvalonLoggerthat will log to a child of theLoggerset by callingsetDefaultLogger(org.apache.avalon.framework.logger.Logger).AvalonLogger(org.apache.avalon.framework.logger.Logger logger) Constructs anAvalonLoggerthat outputs to the givenLoggerinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidLogs a message withorg.apache.avalon.framework.logger.Logger.debug.voidLogs a message withorg.apache.avalon.framework.logger.Logger.debug.voidLogs a message withorg.apache.avalon.framework.logger.Logger.error.voidLogs a message withorg.apache.avalon.framework.logger.Logger.error.voidLogs a message withorg.apache.avalon.framework.logger.Logger.fatalError.voidLogs a message withorg.apache.avalon.framework.logger.Logger.fatalError.org.apache.avalon.framework.logger.LoggerGets the Avalon logger implementation used to perform logging.voidLogs a message withorg.apache.avalon.framework.logger.Logger.info.voidLogs a message withorg.apache.avalon.framework.logger.Logger.info.booleanIs logging toorg.apache.avalon.framework.logger.Logger.debugenabled?booleanIs logging toorg.apache.avalon.framework.logger.Logger.errorenabled?booleanIs logging toorg.apache.avalon.framework.logger.Logger.fatalErrorenabled?booleanIs logging toorg.apache.avalon.framework.logger.Logger.infoenabled?booleanIs logging toorg.apache.avalon.framework.logger.Logger.debugenabled?booleanIs logging toorg.apache.avalon.framework.logger.Logger.warnenabled?static voidsetDefaultLogger(org.apache.avalon.framework.logger.Logger logger) Sets the ancestral Avalon logger from which the delegating loggers will descend.voidLogs a message withorg.apache.avalon.framework.logger.Logger.debug.voidLogs a message withorg.apache.avalon.framework.logger.Logger.debug.voidLogs a message withorg.apache.avalon.framework.logger.Logger.warn.voidLogs a message withorg.apache.avalon.framework.logger.Logger.warn.
-
Field Details
-
defaultLogger
private static volatile org.apache.avalon.framework.logger.Logger defaultLoggerAncestral Avalon logger. -
logger
private final transient org.apache.avalon.framework.logger.Logger loggerAvalon logger used to perform log.
-
-
Constructor Details
-
AvalonLogger
public AvalonLogger(org.apache.avalon.framework.logger.Logger logger) Constructs anAvalonLoggerthat outputs to the givenLoggerinstance.- Parameters:
logger- the Avalon logger implementation to delegate to
-
AvalonLogger
Constructs anAvalonLoggerthat will log to a child of theLoggerset by callingsetDefaultLogger(org.apache.avalon.framework.logger.Logger).- Parameters:
name- the name of the avalon logger implementation to delegate to
-
-
Method Details
-
getLogger
public org.apache.avalon.framework.logger.Logger getLogger()Gets the Avalon logger implementation used to perform logging.- Returns:
- avalon logger implementation
-
setDefaultLogger
public static void setDefaultLogger(org.apache.avalon.framework.logger.Logger logger) Sets the ancestral 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
-
debug
Logs a message withorg.apache.avalon.framework.logger.Logger.debug. -
debug
Logs a message withorg.apache.avalon.framework.logger.Logger.debug. -
error
Logs a message withorg.apache.avalon.framework.logger.Logger.error. -
error
Logs a message withorg.apache.avalon.framework.logger.Logger.error. -
fatal
Logs a message withorg.apache.avalon.framework.logger.Logger.fatalError. -
fatal
Logs a message withorg.apache.avalon.framework.logger.Logger.fatalError. -
info
Logs a message withorg.apache.avalon.framework.logger.Logger.info. -
info
Logs a message withorg.apache.avalon.framework.logger.Logger.info. -
isDebugEnabled
public boolean isDebugEnabled()Is logging toorg.apache.avalon.framework.logger.Logger.debugenabled?- Specified by:
isDebugEnabledin interfaceLog- Returns:
- true if debug is enabled in the underlying logger.
- See Also:
-
isErrorEnabled
public boolean isErrorEnabled()Is logging toorg.apache.avalon.framework.logger.Logger.errorenabled?- Specified by:
isErrorEnabledin interfaceLog- Returns:
- true if error is enabled in the underlying logger.
- See Also:
-
isFatalEnabled
public boolean isFatalEnabled()Is logging toorg.apache.avalon.framework.logger.Logger.fatalErrorenabled?- Specified by:
isFatalEnabledin interfaceLog- Returns:
- true if fatal is enabled in the underlying logger.
- See Also:
-
isInfoEnabled
public boolean isInfoEnabled()Is logging toorg.apache.avalon.framework.logger.Logger.infoenabled?- Specified by:
isInfoEnabledin interfaceLog- Returns:
- true if info is enabled in the underlying logger.
- See Also:
-
isTraceEnabled
public boolean isTraceEnabled()Is logging toorg.apache.avalon.framework.logger.Logger.debugenabled?- Specified by:
isTraceEnabledin interfaceLog- Returns:
- true if trace is enabled in the underlying logger.
- See Also:
-
isWarnEnabled
public boolean isWarnEnabled()Is logging toorg.apache.avalon.framework.logger.Logger.warnenabled?- Specified by:
isWarnEnabledin interfaceLog- Returns:
- true if warn is enabled in the underlying logger.
- See Also:
-
trace
Logs a message withorg.apache.avalon.framework.logger.Logger.debug. -
trace
Logs a message withorg.apache.avalon.framework.logger.Logger.debug. -
warn
Logs a message withorg.apache.avalon.framework.logger.Logger.warn. -
warn
Logs a message withorg.apache.avalon.framework.logger.Logger.warn.
-