Logger Artifact

Overview

The Logger defines a implementation independent logging channel. The logging channel supplied to a component represents the root loggging channel for the component. A component may aquire additional subsidiary channels using the getChildLogger() operation. The Logger interface exposes a set of operations to check if a particular logging priority is enabled, thus enabling optimization of typically expensive string manipulation operations related to log message construction.

Delivery Strategies

A logging channel may be supplied via constructor or under an implementation of the LogEnabled lifecycle stage interface.

Example

An implementation may declare is usage of subsidiary logging channels to a management facility through the @avalon.logger source markup tag.

Example:

  /**
   * Creation of a new widget. The implementation assigns 
   * the supplied logging channel as the default channel and 
   * constructs a subsidiary channel for connection related log 
   * messages. 
   *
   * @param logger a logging channel
   * @avalon.logger name="connection"
   */
   public DefaultWidget( Logger logger ) 
   {
       m_logger = logger;
       m_connectionLogger = logger.getChildLogger( "connection" );

       if( m_logger.isDebugEnabled() )
       {
           final String message =
             "Widget established.";
           m_logger.debug( message );
       }
   }