Package org.geotools.util.logging
Class Log4J2LoggerFactory
- Object
-
- LoggerFactory<Logger>
-
- Log4J2LoggerFactory
-
public class Log4J2LoggerFactory extends LoggerFactory<Logger>
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 callGeoTools.setLoggerFactory(Log4J2LoggerFactory#getInstance()).- Since:
- 27
- Author:
- Jody Garnett (GeoCat)
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLog4J2LoggerFactory()Constructs a default factory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected LoggergetImplementation(String name)Returns the implementation to use for the logger of the specified name, ornullif the logger would delegates to Java logging anyway.static Log4J2LoggerFactorygetInstance()Returns the unique instance of this factory.StringlookupConfiguration()Indication of Log4J configuration details, often a configuration filename or setting.protected Loggerunwrap(Logger logger)Returns the implementation wrapped by the specified logger, ornullif none.protected Loggerwrap(String name, Logger implementation)Wraps the specified implementation in a Java logger.-
Methods inherited from class LoggerFactory
getImplementationClass, getLogger
-
-
-
-
Constructor Detail
-
Log4J2LoggerFactory
protected Log4J2LoggerFactory() throws NoClassDefFoundErrorConstructs a default factory.- Throws:
NoClassDefFoundError- if Apache'sLogclass was not found on the classpath.
-
-
Method Detail
-
getInstance
public static Log4J2LoggerFactory getInstance() throws NoClassDefFoundError
Returns the unique instance of this factory.- Throws:
NoClassDefFoundError- if Apache'sLogclass was not found on the classpath.
-
getImplementation
protected Logger getImplementation(String name)
Returns the implementation to use for the logger of the specified name, ornullif the logger would delegates to Java logging anyway.- Specified by:
getImplementationin classLoggerFactory<Logger>- 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 Logger wrap(String name, Logger implementation)
Wraps the specified implementation in a Java logger.- Specified by:
wrapin 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
protected Logger unwrap(Logger logger)
Returns the implementation wrapped by the specified logger, ornullif none.- Specified by:
unwrapin classLoggerFactory<Logger>- Parameters:
logger- The logger to test.- Returns:
- The implementation wrapped by the specified logger, or
nullif none.
-
lookupConfiguration
public String lookupConfiguration()
Indication of Log4J configuration details, often a configuration filename or setting.- Overrides:
lookupConfigurationin classLoggerFactory<Logger>- Returns:
- Log4J configuration details, often a filename or setting.
-
-