org.geotools.util.logging
Class Log4JLoggerFactory

java.lang.Object
  extended by org.geotools.util.logging.LoggerFactory<org.apache.log4j.Logger>
      extended by org.geotools.util.logging.Log4JLoggerFactory

public class Log4JLoggerFactory
extends LoggerFactory<org.apache.log4j.Logger>

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

Since:
2.4
Version:
$Id: Log4JLoggerFactory.java 30640 2008-06-12 17:34:32Z acuster $
Author:
Martin Desruisseaux

Constructor Summary
protected Log4JLoggerFactory()
          Constructs a default factory.
 
Method Summary
protected  org.apache.log4j.Logger getImplementation(java.lang.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 Log4JLoggerFactory getInstance()
          Returns the unique instance of this factory.
protected  org.apache.log4j.Logger unwrap(java.util.logging.Logger logger)
          Returns the implementation wrapped by the specified logger, or null if none.
protected  java.util.logging.Logger wrap(java.lang.String name, org.apache.log4j.Logger implementation)
          Wraps the specified implementation in a Java logger.
 
Methods inherited from class org.geotools.util.logging.LoggerFactory
getImplementationClass, getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log4JLoggerFactory

protected Log4JLoggerFactory()
                      throws java.lang.NoClassDefFoundError
Constructs a default factory.

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

getInstance

public static Log4JLoggerFactory getInstance()
                                      throws java.lang.NoClassDefFoundError
Returns the unique instance of this factory.

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

getImplementation

protected org.apache.log4j.Logger getImplementation(java.lang.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<org.apache.log4j.Logger>
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 java.util.logging.Logger wrap(java.lang.String name,
                                        org.apache.log4j.Logger implementation)
Wraps the specified implementation in a Java logger.

Specified by:
wrap in class LoggerFactory<org.apache.log4j.Logger>
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 org.apache.log4j.Logger unwrap(java.util.logging.Logger logger)
Returns the implementation wrapped by the specified logger, or null if none.

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


Copyright © 1996-2010 Geotools. All Rights Reserved.