public final class LoggerFactory extends Object
LoggerFactory is customized to support accessing an
SLF4J implementation that is on the classpath of a child class loader.
Thus, the preferred class loader for binding with the SLF4J implementation
(which implies loading the org.slf4j.impl.StaticLoggerBinder class)
is the context class loader of
the thread that triggers the logging system initialization. This will
typically be the Catalina class loader, which defaults to the common class
loader in Tomcat.
After it is loaded, the access to the separate StaticLoggerBinder
class is delegated to the SeparateSLF4JImplBridge helper.
This class is supposed to shadow the original LoggerFactory.
Thus, the juli-to-slf4j.jar should be placed before the
slf4j-api.jar on the Catalina startup classpath (see the
catalina.sh startup script for more details).
Inherited documentation from SLF4J API:
TheLoggerFactoryis a utility class producing Loggers for various logging APIs, most notably for log4j, logback and JDK 1.4 logging. Other implementations such asorg.slf4j.impl.NOPLoggerandorg.slf4j.impl.SimpleLoggerare also supported.
LoggerFactoryis essentially a wrapper around anILoggerFactoryinstance bound withLoggerFactoryat compile time.Please note that all methods in
LoggerFactoryare static.
Which is unfortunately incorrect: the ILoggerFactory instance is
bound at runtime.
| Modifier and Type | Method and Description |
|---|---|
static org.slf4j.ILoggerFactory |
getILoggerFactory()
Return the
ILoggerFactory instance in use. |
static org.slf4j.Logger |
getLogger(Class<?> clazz)
Return a logger named corresponding to the class passed as parameter,
using the statically bound
ILoggerFactory instance. |
static org.slf4j.Logger |
getLogger(String name)
Return a logger named according to the name parameter using the
statically bound
ILoggerFactory instance. |
public static org.slf4j.Logger getLogger(String name)
ILoggerFactory instance.name - The name of the logger.public static org.slf4j.Logger getLogger(Class<?> clazz)
ILoggerFactory 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 the
slf4j.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.
clazz - the returned logger will be named after clazzpublic static org.slf4j.ILoggerFactory getILoggerFactory()
ILoggerFactory instance in use.
ILoggerFactory instance is bound with this class at compile time.
Copyright © 2015–2017. All rights reserved.