org.geotools.util.logging
Class CommonsLoggerFactory

Object
  extended by LoggerFactory<Log>
      extended by CommonsLoggerFactory

public class CommonsLoggerFactory
extends LoggerFactory<Log>

A factory for loggers that redirect all Java logging events to the Apache's Commons-logging framework.

Since:
2.4
Author:
Martin Desruisseaux
Module:
modules/library/metadata (gt-metadata.jar)

Constructor Summary
protected CommonsLoggerFactory()
          Constructs a default factory.
 
Method Summary
protected  Log getImplementation(String name)
          Returns the implementation to use for the logger of the specified name, or null if the logger would delegates to Java logging anyway.
static CommonsLoggerFactory getInstance()
          Returns the unique instance of this factory.
protected  Log unwrap(Logger logger)
          Returns the implementation wrapped by the specified logger, or null if none.
protected  Logger wrap(String name, Log implementation)
          Wraps the specified implementation in a Java logger.
 
Methods inherited from class LoggerFactory
getImplementationClass, getLogger
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonsLoggerFactory

protected CommonsLoggerFactory()
                        throws NoClassDefFoundError
Constructs a default factory.

Throws:
NoClassDefFoundError - if Apache's Log class was not found on the classpath.
Method Detail

getInstance

public static CommonsLoggerFactory getInstance()
                                        throws NoClassDefFoundError
Returns the unique instance of this factory.

Throws:
NoClassDefFoundError - if Apache's Log class was not found on the classpath.

getImplementation

protected Log getImplementation(String name)
Returns the implementation to use for the logger of the specified name, or null if the logger would delegates to Java logging anyway.

Specified by:
getImplementation in class LoggerFactory<Log>
Parameters:
name - The name of the logger.
Returns:
The logger as an object of the target logging framework (Log4J, SLF4J, etc.), or null if the target framework would redirect to the Java logging framework.

wrap

protected Logger wrap(String name,
                      Log implementation)
Wraps the specified implementation in a Java logger.

Specified by:
wrap in class LoggerFactory<Log>
Parameters:
name - The name of the logger.
implementation - An implementation returned by LoggerFactory.getImplementation(java.lang.String).
Returns:
A new logger wrapping the specified implementation.

unwrap

protected Log unwrap(Logger logger)
Returns the implementation wrapped by the specified logger, or null if none.

Specified by:
unwrap in class LoggerFactory<Log>
Parameters:
logger - The logger to test.
Returns:
The implementation wrapped by the specified logger, or null if none.


Copyright © 1996-2009 Geotools. All Rights Reserved.