Class LogToSelfDecorator

  extended byorg.apache.avalon.excalibur.logger.decorator.LoggerManagerDecorator
      extended byorg.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.

CVS $Revision: 1.4 $ $Date: 2004/03/10 13:54:50 $
Avalon Development Team

Field Summary
Fields inherited from class org.apache.avalon.excalibur.logger.decorator.LoggerManagerDecorator
Fields inherited from interface org.apache.avalon.excalibur.logger.LoggerManager
Constructor Summary
LogToSelfDecorator(LoggerManager loggerManager, java.lang.String switchTo)
          Creates a LogToSelfDecorator instance.
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 org.apache.avalon.excalibur.logger.decorator.LoggerManagerDecorator
configure, contextualize, dispose, getDefaultLogger, getLoggerForCategory, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public LogToSelfDecorator(LoggerManager loggerManager,
                          java.lang.String switchTo)
Creates a LogToSelfDecorator instance.

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.
Method Detail


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
enableLogging in class LoggerManagerDecorator
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.


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
start in class LoggerManagerDecorator

Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.