Package org.slf4j
Class LoggerFactory
java.lang.Object
org.slf4j.LoggerFactory
The
LoggerFactory
is a utility class producing Loggers for
various logging APIs, most notably for log4j, logback and JDK 1.4 logging.
Other implementations such as NOPLogger
and
SimpleLogger
are also supported.
LoggerFactory
is essentially a wrapper around an
ILoggerFactory
instance bound with LoggerFactory
at
compile time.
Please note that all methods in LoggerFactory
are static.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String[]
It is LoggerFactory's responsibility to track version changes and manage the compatibility list.(package private) static final String
(package private) static boolean
(package private) static final String
(package private) static final int
(package private) static int
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final NOPLoggerFactory
(package private) static final int
(package private) static final String
(package private) static final int
(package private) static final String
private static String
(package private) static final SubstituteLoggerFactory
(package private) static final String
(package private) static final int
(package private) static final int
(package private) static final String
(package private) static final String
(package private) static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static final void
bind()
private static void
emitReplayOrSubstituionWarning
(SubstituteLoggingEvent event, int queueSize) private static void
emitReplayWarning
(int eventCount) private static void
(package private) static void
private static void
static ILoggerFactory
Return theILoggerFactory
instance in use.static Logger
Return a logger named corresponding to the class passed as parameter, using the statically boundILoggerFactory
instance.static Logger
Return a logger named according to the name parameter using the statically boundILoggerFactory
instance.private static boolean
isAmbiguousStaticLoggerBinderPathSet
(Set<URL> binderPathSet) private static boolean
private static boolean
private static boolean
nonMatchingClasses
(Class<?> clazz, Class<?> autoComputedCallingClass) private static final void
private static void
private static void
private static void
private static void
reportActualBinding
(Set<URL> binderPathSet) private static void
reportMultipleBindingAmbiguity
(Set<URL> binderPathSet) Prints a warning message on the console if multiple bindings were found on the class path.(package private) static void
reset()
Force LoggerFactory to consider itself uninitialized.private static final void
-
Field Details
-
CODES_PREFIX
- See Also:
-
NO_STATICLOGGERBINDER_URL
- See Also:
-
MULTIPLE_BINDINGS_URL
- See Also:
-
NULL_LF_URL
- See Also:
-
VERSION_MISMATCH
- See Also:
-
SUBSTITUTE_LOGGER_URL
- See Also:
-
LOGGER_NAME_MISMATCH_URL
- See Also:
-
REPLAY_URL
- See Also:
-
UNSUCCESSFUL_INIT_URL
- See Also:
-
UNSUCCESSFUL_INIT_MSG
- See Also:
-
UNINITIALIZED
static final int UNINITIALIZED- See Also:
-
ONGOING_INITIALIZATION
static final int ONGOING_INITIALIZATION- See Also:
-
FAILED_INITIALIZATION
static final int FAILED_INITIALIZATION- See Also:
-
SUCCESSFUL_INITIALIZATION
static final int SUCCESSFUL_INITIALIZATION- See Also:
-
NOP_FALLBACK_INITIALIZATION
static final int NOP_FALLBACK_INITIALIZATION- See Also:
-
INITIALIZATION_STATE
static volatile int INITIALIZATION_STATE -
SUBST_FACTORY
-
NOP_FALLBACK_FACTORY
-
DETECT_LOGGER_NAME_MISMATCH_PROPERTY
- See Also:
-
JAVA_VENDOR_PROPERTY
- See Also:
-
DETECT_LOGGER_NAME_MISMATCH
static boolean DETECT_LOGGER_NAME_MISMATCH -
API_COMPATIBILITY_LIST
It is LoggerFactory's responsibility to track version changes and manage the compatibility list. It is assumed that all versions in the 1.6 are mutually compatible. -
STATIC_LOGGER_BINDER_PATH
-
-
Constructor Details
-
LoggerFactory
private LoggerFactory()
-
-
Method Details
-
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. -
performInitialization
private static final void performInitialization() -
messageContainsOrgSlf4jImplStaticLoggerBinder
-
bind
private static final void bind() -
postBindCleanUp
private static void postBindCleanUp() -
fixSubstituteLoggers
private static void fixSubstituteLoggers() -
failedBinding
-
replayEvents
private static void replayEvents() -
emitReplayOrSubstituionWarning
-
replaySingleEvent
-
emitSubstitutionWarning
private static void emitSubstitutionWarning() -
emitReplayWarning
private static void emitReplayWarning(int eventCount) -
versionSanityCheck
private static final void versionSanityCheck() -
findPossibleStaticLoggerBinderPathSet
-
isAmbiguousStaticLoggerBinderPathSet
-
reportMultipleBindingAmbiguity
Prints a warning message on the console if multiple bindings were found on the class path. No reporting is done otherwise. -
isAndroid
private static boolean isAndroid() -
reportActualBinding
-
getLogger
Return a logger named according to the name parameter using the statically boundILoggerFactory
instance.- Parameters:
name
- The name of the logger.- Returns:
- logger
-
getLogger
Return a logger named corresponding to the class passed as parameter, using the statically boundILoggerFactory
instance.In case the the
clazz
parameter differs from the name of the caller as computed internally by SLF4J, a logger name mismatch warning will be printed but only if theslf4j.detectLoggerNameMismatch
system 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:
-
nonMatchingClasses
-
getILoggerFactory
Return theILoggerFactory
instance in use. ILoggerFactory instance is bound with this class at compile time.- Returns:
- the ILoggerFactory instance in use
-