Package org.geotools.util.logging
Class LoggerFactory<L>
- Object
-
- LoggerFactory<L>
-
- Direct Known Subclasses:
CommonsLoggerFactory,DefaultLoggerFactory,Log4J2LoggerFactory,Log4JLoggerFactory,LogbackLoggerFactory
public abstract class LoggerFactory<L> extends Object
A factory for JavaLoggerwrapping an other logging framework. This factory is used only when wanting to log to an other framework than Java logging. ThegetLogger(java.lang.String)method returns some subclass ofLogger(typicalllyLoggerAdapter) that forward directly all log methods to an other framework.- Since:
- 2.4
- Author:
- Martin Desruisseaux
- See Also:
Logging,LoggerAdapter
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLoggerFactory(Class<L> loggerClass)Creates a new factory.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract LgetImplementation(String name)Returns the implementation to use for the logger of the specified name.Class<L>getImplementationClass()Returns the base class of objects to be returned bygetImplementation(java.lang.String).LoggergetLogger(String name)Returns the logger of the specified name, ornull.StringlookupConfiguration()Look up configuration information, ornullunknown.protected abstract Lunwrap(Logger logger)Returns the implementation wrapped by the specified logger, ornullif none.protected abstract Loggerwrap(String name, L implementation)Wraps the specified implementation in a Java logger.
-
-
-
Method Detail
-
getLogger
public Logger getLogger(String name)
Returns the logger of the specified name, ornull. If this method has already been invoked previously with the samenameargument, then it may returns the same logger provided that:- the logger has not yet been garbage collected;
- the implementation instance (Log4J, SLF4J, etc.) returned by
getImplementation(name)has not changed.
Loggerinstance, ornullif the standard Java logging framework should be used.- Parameters:
name- The name of the logger.- Returns:
- The logger, or
null.
-
getImplementationClass
public Class<L> getImplementationClass()
Returns the base class of objects to be returned bygetImplementation(java.lang.String). The class depends on the underlying logging framework (Log4J, SLF4J, etc.).
-
getImplementation
protected abstract L getImplementation(String name)
Returns the implementation to use for the logger of the specified name. The object to be returned depends on the logging framework (Log4J, SLF4J, etc.). If the target framework redirects logging events to Java logging, then this method should returnsnullsince we should not use wrapper at all.- Parameters:
name- The name of the logger.- Returns:
- The logger as an object of the target logging framework (Log4J, SLF4J, etc.), or
nullif the target framework would redirect to the Java logging framework.
-
wrap
protected abstract Logger wrap(String name, L implementation)
Wraps the specified implementation in a Java logger.- Parameters:
name- The name of the logger.implementation- An implementation returned bygetImplementation(java.lang.String).- Returns:
- A new logger wrapping the specified implementation.
-
unwrap
protected abstract L unwrap(Logger logger)
Returns the implementation wrapped by the specified logger, ornullif none. If the specified logger is not an instance of the expected class, then this method should returnsnull.- Parameters:
logger- The logger to test.- Returns:
- The implementation wrapped by the specified logger, or
nullif none.
-
lookupConfiguration
public String lookupConfiguration()
Look up configuration information, ornullunknown.Report back details on how logging configuration is setup. Ideally including configuration filename along with any system properties used.
- Returns:
- configuration information, or
nullunknown.
-
-