Package org.slf4j
Class LoggerFactory
- java.lang.Object
-
- org.slf4j.LoggerFactory
-
public final class LoggerFactory extends Object
TheLoggerFactoryis a utility class producing Loggers for various logging APIs, most notably for log4j, logback and JDK 1.4 logging. Other implementations such asNOPLoggerandSimpleLoggerare also supported.LoggerFactoryis essentially a wrapper around anILoggerFactoryinstance bound withLoggerFactoryat compile time. Please note that all methods inLoggerFactoryare static.- Author:
- Alexander Dorokhine, Robert Elliot, Ceki Gülcü
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static StringCODES_PREFIX(package private) static booleanDETECT_LOGGER_NAME_MISMATCH(package private) static StringDETECT_LOGGER_NAME_MISMATCH_PROPERTY(package private) static intFAILED_INITIALIZATION(package private) static intINITIALIZATION_STATE(package private) static StringJAVA_VENDOR_PROPERTY(package private) static StringLOGGER_NAME_MISMATCH_URL(package private) static StringMULTIPLE_BINDINGS_URL(package private) static StringNO_STATICLOGGERBINDER_URL(package private) static NOPLoggerFactoryNOP_FALLBACK_FACTORY(package private) static intNOP_FALLBACK_INITIALIZATION(package private) static StringNULL_LF_URL(package private) static intONGOING_INITIALIZATION(package private) static StringREPLAY_URL(package private) static SubstituteLoggerFactorySUBST_FACTORY(package private) static StringSUBSTITUTE_LOGGER_URL(package private) static intSUCCESSFUL_INITIALIZATION(package private) static intUNINITIALIZED(package private) static StringUNSUCCESSFUL_INIT_MSG(package private) static StringUNSUCCESSFUL_INIT_URL(package private) static StringVERSION_MISMATCH
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static voidfailedBinding(Throwable t)(package private) static Set<URL>findPossibleStaticLoggerBinderPathSet()static ILoggerFactorygetILoggerFactory()Return theILoggerFactoryinstance in use.static LoggergetLogger(Class<?> clazz)Return a logger named corresponding to the class passed as parameter, using the statically boundILoggerFactoryinstance.static LoggergetLogger(String name)Return a logger named according to the name parameter using the statically boundILoggerFactoryinstance.(package private) static voidreset()Force LoggerFactory to consider itself uninitialized.
-
-
-
Field Detail
-
CODES_PREFIX
static final String CODES_PREFIX
- See Also:
- Constant Field Values
-
NO_STATICLOGGERBINDER_URL
static final String NO_STATICLOGGERBINDER_URL
- See Also:
- Constant Field Values
-
MULTIPLE_BINDINGS_URL
static final String MULTIPLE_BINDINGS_URL
- See Also:
- Constant Field Values
-
NULL_LF_URL
static final String NULL_LF_URL
- See Also:
- Constant Field Values
-
VERSION_MISMATCH
static final String VERSION_MISMATCH
- See Also:
- Constant Field Values
-
SUBSTITUTE_LOGGER_URL
static final String SUBSTITUTE_LOGGER_URL
- See Also:
- Constant Field Values
-
LOGGER_NAME_MISMATCH_URL
static final String LOGGER_NAME_MISMATCH_URL
- See Also:
- Constant Field Values
-
REPLAY_URL
static final String REPLAY_URL
- See Also:
- Constant Field Values
-
UNSUCCESSFUL_INIT_URL
static final String UNSUCCESSFUL_INIT_URL
- See Also:
- Constant Field Values
-
UNSUCCESSFUL_INIT_MSG
static final String UNSUCCESSFUL_INIT_MSG
- See Also:
- Constant Field Values
-
UNINITIALIZED
static final int UNINITIALIZED
- See Also:
- Constant Field Values
-
ONGOING_INITIALIZATION
static final int ONGOING_INITIALIZATION
- See Also:
- Constant Field Values
-
FAILED_INITIALIZATION
static final int FAILED_INITIALIZATION
- See Also:
- Constant Field Values
-
SUCCESSFUL_INITIALIZATION
static final int SUCCESSFUL_INITIALIZATION
- See Also:
- Constant Field Values
-
NOP_FALLBACK_INITIALIZATION
static final int NOP_FALLBACK_INITIALIZATION
- See Also:
- Constant Field Values
-
INITIALIZATION_STATE
static volatile int INITIALIZATION_STATE
-
SUBST_FACTORY
static final SubstituteLoggerFactory SUBST_FACTORY
-
NOP_FALLBACK_FACTORY
static final NOPLoggerFactory NOP_FALLBACK_FACTORY
-
DETECT_LOGGER_NAME_MISMATCH_PROPERTY
static final String DETECT_LOGGER_NAME_MISMATCH_PROPERTY
- See Also:
- Constant Field Values
-
JAVA_VENDOR_PROPERTY
static final String JAVA_VENDOR_PROPERTY
- See Also:
- Constant Field Values
-
DETECT_LOGGER_NAME_MISMATCH
static boolean DETECT_LOGGER_NAME_MISMATCH
-
-
Method Detail
-
reset
static void reset()
Force LoggerFactory to consider itself uninitialized. This method is intended to be called by classes (in the same package) for testing purposes. This method is internal. It can be modified, renamed or removed at any time without notice. You are strongly discouraged from calling this method in production code.
-
failedBinding
static void failedBinding(Throwable t)
-
getLogger
public static Logger getLogger(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(Class<?> clazz)
Return a logger named corresponding to the class passed as parameter, using the statically boundILoggerFactoryinstance.In case the 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
-
-