org.geotoolkit.util.logging
Class Log4JLoggerFactory

Object
  extended by LoggerFactory<Logger>
      extended by Log4JLoggerFactory

public class Log4JLoggerFactory
extends LoggerFactory<Logger>

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

It is not necessary to use this class directly. The Geotk library will use this factory automatically if the geotk-logging-log4j.jar file is present on the classpath.

Since:
2.4
Version:
3.00
Author:
Martin Desruisseaux (IRD)
Module:
utility/geotk-logging-log4j (download)    View source code for this class

Field Summary
 
Fields inherited from class LoggerFactory
COMMONS_LOGGING, LOG4J
 
Constructor Summary
Log4JLoggerFactory()
          Constructs a default factory.
 
Method Summary
protected  Logger 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 Log4JLoggerFactory getInstance()
          Deprecated. Replaced by the META-INF/services discovery mechanism.
protected  Logger unwrap(Logger logger)
          Returns the implementation wrapped by the specified logger, or null if none.
protected  Logger wrap(String name, Logger 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

Log4JLoggerFactory

public Log4JLoggerFactory()
                   throws NoClassDefFoundError
Constructs a default factory.

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

getInstance

@Deprecated
public static Log4JLoggerFactory getInstance()
                                      throws NoClassDefFoundError
Deprecated. Replaced by the META-INF/services discovery mechanism.

Returns the unique instance of this factory.

Returns:
The unique instance of this factory.
Throws:
NoClassDefFoundError - if Apache Log class was not found on the classpath.

getImplementation

protected Logger 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<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 Logger wrap(String name,
                      Logger implementation)
Wraps the specified implementation in a Java logger.

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

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


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.