Package org.geotools.util.logging
Class Log4J2LoggerFactory
Object
LoggerFactory<Logger>
Log4J2LoggerFactory
A factory for loggers that redirect all Java logging events to the Apache's Log4J framework.
The GeoTools.init()
method will select Log4J2LoggerFactory if log4j api is available on the classpath,
however if you have several logging libraries on the classpath call
GeoTools.setLoggerFactory(Log4J2LoggerFactory#getInstance())
.
- Since:
- 27
- Author:
- Jody Garnett (GeoCat)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Logger
getImplementation
(String name) Returns the implementation to use for the logger of the specified name, ornull
if the logger would delegates to Java logging anyway.static Log4J2LoggerFactory
Returns the unique instance of this factory.Indication of Log4J configuration details, often a configuration filename or setting.protected Logger
Returns the implementation wrapped by the specified logger, ornull
if none.protected Logger
Wraps the specified implementation in a Java logger.Methods inherited from class LoggerFactory
getImplementationClass, getLogger
-
Constructor Details
-
Log4J2LoggerFactory
Constructs a default factory.- Throws:
NoClassDefFoundError
- if Apache'sLog
class was not found on the classpath.
-
-
Method Details
-
getInstance
Returns the unique instance of this factory.- Throws:
NoClassDefFoundError
- if Apache'sLog
class was not found on the classpath.
-
getImplementation
Returns the implementation to use for the logger of the specified name, ornull
if the logger would delegates to Java logging anyway.- Specified by:
getImplementation
in classLoggerFactory<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
Wraps the specified implementation in a Java logger.- Specified by:
wrap
in classLoggerFactory<Logger>
- Parameters:
name
- The name of the logger.implementation
- An implementation returned byLoggerFactory.getImplementation(java.lang.String)
.- Returns:
- A new logger wrapping the specified implementation.
-
unwrap
Returns the implementation wrapped by the specified logger, ornull
if none.- Specified by:
unwrap
in classLoggerFactory<Logger>
- Parameters:
logger
- The logger to test.- Returns:
- The implementation wrapped by the specified logger, or
null
if none.
-
lookupConfiguration
Indication of Log4J configuration details, often a configuration filename or setting.- Overrides:
lookupConfiguration
in classLoggerFactory<Logger>
- Returns:
- Log4J configuration details, often a filename or setting.
-