L
- The type of loggers used for the implementation backend.
This is the type used by external frameworks like Log4J.@ThreadSafe public abstract class LoggerFactory<L> extends Object
Logger
wrapping an other logging framework.
This factory is used only when an application wants to redirect SIS logs to an other framework
than JDK logging. An instance of LoggerFactory
can be registered to SIS in two ways:
LoggerFactory
implementation
in the META-INF/services/org.apache.sis.util.logging.LoggerFactory
file.
Note that the sis-logging-commons.jar
and sis-logging-log4j.jar
files provide such declaration.Logging.setLoggerFactory(LoggerFactory)
at application initialization time.getLogger(String)
method shall return some Logger
subclass
(typically LoggerAdapter
) which forwards directly all log methods to the other framework.Logging
,
LoggerAdapter
Defined in the sis-utility module
Modifier | Constructor and Description |
---|---|
protected |
LoggerFactory(Class<L> loggerClass)
Creates a new factory.
|
Modifier and Type | Method and Description |
---|---|
protected abstract L |
getImplementation(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 by
getImplementation(String) . |
Logger |
getLogger(String name)
Returns the logger of the specified name, or
null if the JDK logging framework
should be used. |
abstract String |
getName()
Returns the name of the logging framework.
|
protected abstract L |
unwrap(Logger logger)
Returns the implementation wrapped by the specified
logger, or
null if none. |
protected abstract Logger |
wrap(String name,
L implementation)
Wraps the specified implementation in a JDK logger.
|
public abstract String getName()
public Logger getLogger(String name)
null
if the JDK logging framework
should be used.name
- The name of the logger.null
if the JDK logging framework should be used.public Class<L> getImplementationClass()
getImplementation(String)
.
The class depends on the underlying logging framework (Log4J, SLF4J, etc.).protected abstract L getImplementation(String name)
null
since we should not use wrapper at all.name
- The name of the logger.null
if the target framework would redirect
to the JDK logging framework.protected abstract Logger wrap(String name, L implementation)
name
- The name of the logger.implementation
- An implementation returned by getImplementation(String)
.protected abstract L unwrap(Logger logger)
null
if none. If the specified logger is not an instance of the expected
class, then this method should returns null
.logger
- The logger to test.null
if none.Copyright © 2010–2013 The Apache Software Foundation. All rights reserved.