Package org.slf4j
Class LoggerFactory
- java.lang.Object
-
- org.slf4j.LoggerFactory
-
public final class LoggerFactory extends java.lang.Object
TheLoggerFactoryis a utility class producing Loggers for various logging APIs, e.g. logback, reload4j, log4j and JDK 1.4 logging. Other implementations such asNOPLoggerand SimpleLogger are also supported.LoggerFactoryis essentially a wrapper around anILoggerFactoryinstance provided by aSLF4JServiceProvider.Please note that all methods in
LoggerFactoryare static.- Author:
- Alexander Dorokhine, Robert Elliot, Ceki Gülcü
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPROVIDER_PROPERTY_KEYSystem property for explicitly setting the provider class.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ILoggerFactorygetILoggerFactory()Return theILoggerFactoryinstance in use.static LoggergetLogger(java.lang.Class<?> clazz)Return a logger named corresponding to the class passed as parameter, using the statically boundILoggerFactoryinstance.static LoggergetLogger(java.lang.String name)Return a logger named according to the name parameter using the statically boundILoggerFactoryinstance.
-
-
-
Field Detail
-
PROVIDER_PROPERTY_KEY
public static final java.lang.String PROVIDER_PROPERTY_KEY
System property for explicitly setting the provider class. If set and the provider could be instantiated, then the service loading mechanism will be bypassed.- Since:
- 2.0.9
- See Also:
- Constant Field Values
-
-
Method Detail
-
getLogger
public static Logger getLogger(java.lang.String name)
Return a logger named according to the name parameter using the statically boundILoggerFactoryinstance.- Parameters:
name- The name of the logger.- Returns:
- logger
-
getLogger
public static Logger getLogger(java.lang.Class<?> clazz)
Return a logger named corresponding to the class passed as parameter, using the statically boundILoggerFactoryinstance.In case the
clazzparameter differs from the name of the caller as computed internally by SLF4J, a logger name mismatch warning will be printed but only if theslf4j.detectLoggerNameMismatchsystem property is set to true. By default, this property is not set and no warnings will be printed even in case of a logger name mismatch.- Parameters:
clazz- the returned logger will be named after clazz- Returns:
- logger
- See Also:
- Detected logger name mismatch
-
getILoggerFactory
public static ILoggerFactory getILoggerFactory()
Return theILoggerFactoryinstance in use.ILoggerFactory instance is bound with this class at compile time.
- Returns:
- the ILoggerFactory instance in use
-
-