org.apache.avalon.excalibur.logger.decorator
Class LogToSelfDecorator
java.lang.Object
org.apache.avalon.excalibur.logger.decorator.LoggerManagerDecorator
org.apache.avalon.excalibur.logger.decorator.LogToSelfDecorator
- All Implemented Interfaces:
- Configurable, Contextualizable, Disposable, LogEnabled, LoggerManager, Startable
- public class LogToSelfDecorator
- extends LoggerManagerDecorator
This class intercepts the class passed to us via
enableLogging()
and substibutes it
by LoggerSwitch.get()
logger.
Later on at the start()
stage
we assume that our wrapped LoggerManager has already
completely initialized itself and extract
a Logger
from it.
LoggerSwitch
allowes us to supply this
logger to it via LoggerSwitch.setPreferred()
.
This has the effect of all the log messages directed
to LoggerSwitch.get()
obtained logger
being directed to the new Logger
unless
a recursion error happens.
- Since:
- 4.0
- Version:
- CVS $Revision: 1.4 $ $Date: 2004/03/10 13:54:50 $
- Author:
- Avalon Development Team
Fields inherited from interface org.apache.avalon.excalibur.logger.LoggerManager |
ROLE |
Method Summary |
void |
enableLogging(Logger logger)
Substitutes the supplied logger by m_switch.get() . |
void |
start()
Invokes start() on our wrapped
LoggerManager and swithces the
logger used by us and all objects that we
decorate for a logger extracted from our
wrapped LoggerManager . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LogToSelfDecorator
public LogToSelfDecorator(LoggerManager loggerManager,
java.lang.String switchTo)
- Creates a LogToSelfDecorator instance.
- Parameters:
switchTo
- the name of the category we should extract
a Logger and switch our logging to at the
start()
stage; can not be null;
empty value causes logging to be switched to the
"" category.
enableLogging
public void enableLogging(Logger logger)
- Substitutes the supplied logger by
m_switch.get()
.
The substiting logger is used both for our own logging and
passed onto our decorated LoggerManager
.
- Specified by:
enableLogging
in interface LogEnabled
- Overrides:
enableLogging
in class LoggerManagerDecorator
- Parameters:
logger
- the logger supplied for us and our wrapped
LoggerManager; we chould survive with a null logger
(LoggerSwitch create a NullLogger in this case), but
for better error detection we shall rather blow up.
start
public void start()
throws java.lang.Exception
- Invokes
start()
on our wrapped
LoggerManager
and swithces the
logger used by us and all objects that we
decorate for a logger extracted from our
wrapped LoggerManager
.
- Specified by:
start
in interface Startable
- Overrides:
start
in class LoggerManagerDecorator
- Throws:
java.lang.Exception
Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.