public class SLF4JDelegatingLog extends Object implements org.apache.juli.logging.Log, Serializable
Log facade that can be plugged into the default Tomcat JULI logging
system, and supports the SLF4J API to be on Tomcat system classpath and the
SLF4J implementation to be on Tomcat common classpath.
The only supported SLF4J (backend) implementation is Logback.
This facade delegates to SeparateLogbackSupport the task of
automatically bootstrapping Logback at the right time. For this bootstrap to
run properly in multi-thraded environments, a global lock on this
SLF4JDelegatingLog class is used.
The logging behaves differently before and after Logback bootstrap. (Here we refer to the “bootstrap” as being the Logback initialization, which happens during Catalina's startup, but is separate in concept.)
PreBootstrapLoggers that store all
pre-boostrap logging events in memory.Loggers, as returned by the
SLF4J API.
The pluggability of this class relies on an undocumented feature of
LogFactory in the default JULI,
which discovers Log implementation
providers that expose a String-based
constructor.
At pre-bootstrap time, all log events are stored in memory, because we assume that this stage will live a short time (typically less than 200ms) and log few messages (typically 64 messages).
Since version 1.0.1, this implementation properly supports the case were the
underlying logger is a LocationAwareLogger.
Diagnostics can be activated by lowering their detail level with the
org.apache.juli.logging.impl.SLF4JDelegatingLog.diagnostics system
property. Reference values are those defined by the
LocationAwareLogger interface. The default is
LocationAwareLogger.WARN_INT, which only reports problems. Actual
reporting is delegatedJ to SLF4,
which outputs messages to the standard error stream.
SeparateLogbackSupport,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static int |
diagnostics |
protected String |
name
The logger's name.
|
| Constructor and Description |
|---|
SLF4JDelegatingLog()
The default constructor is mandatory, as per the
ServiceLoader specification. |
SLF4JDelegatingLog(String name)
|
| Modifier and Type | Method and Description |
|---|---|
void |
debug(Object msg)
The implementation here converts the message to a string, and logs it as
DEBUG level using the wrapped
Logger instance. |
void |
debug(Object msg,
Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as
DEBUG
level, using the wrapped Logger instance. |
void |
error(Object msg)
The implementation here converts the message to a string, and logs it as
ERROR level using the wrapped
Logger instance. |
void |
error(Object msg,
Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as
ERROR
level, using the wrapped Logger instance. |
void |
fatal(Object msg)
The implementation here converts the message to a string, and logs it as
ERROR level using the wrapped
Logger instance, SLF4J has no FATAL level. |
void |
fatal(Object msg,
Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as
ERROR
level, using the wrapped Logger instance, because SLF4J has no
FATAL level. |
void |
info(Object msg)
The implementation here converts the message to a string, and logs it as
INFO level using the wrapped
Logger instance. |
void |
info(Object msg,
Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as
INFO
level, using the wrapped Logger instance. |
boolean |
isDebugEnabled()
The implementation here delegates to the wrapped
Logger instance. |
boolean |
isErrorEnabled()
The implementation here delegates to the wrapped
Logger instance. |
boolean |
isFatalEnabled()
The implementation here delegates to the
isErrorEnabled method of the wrapped Logger instance, because
SLF4J has no FATAL level. |
boolean |
isInfoEnabled()
The implementation here delegates to the wrapped
Logger instance. |
boolean |
isTraceEnabled()
The implementation here delegates to the wrapped
Logger instance. |
boolean |
isWarnEnabled()
The implementation here delegates to the wrapped
Logger instance. |
protected Object |
readResolve()
Replace the deserialized instance with a fresh new
SLF4JDelegatingLog logger of the same name, so that it properly
belong to the context of the applicable
LogManager. |
void |
trace(Object msg)
The implementation here converts the message to a string, and logs it as
TRACE level using the wrapped
Logger instance. |
void |
trace(Object msg,
Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as
TRACE
level, using the wrapped Logger instance. |
void |
warn(Object msg)
The implementation here converts the message to a string, and logs it as
WARN level using the wrapped
Logger instance. |
void |
warn(Object msg,
Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as
WARN
level, using the wrapped Logger instance. |
public static volatile int diagnostics
protected String name
public SLF4JDelegatingLog()
ServiceLoader specification.
This will construct an unusable Log, though.
public boolean isTraceEnabled()
The implementation here delegates to the wrapped Logger instance.
isTraceEnabled in interface org.apache.juli.logging.Logtrue if the wrapped logger isTraceEnabled, or false otherwise.public boolean isDebugEnabled()
The implementation here delegates to the wrapped Logger instance.
isDebugEnabled in interface org.apache.juli.logging.Logtrue if the wrapped logger isDebugEnabled, or false otherwise.public boolean isInfoEnabled()
The implementation here delegates to the wrapped Logger instance.
isInfoEnabled in interface org.apache.juli.logging.Logtrue if the wrapped logger isInfoEnabled, or false otherwise.public boolean isWarnEnabled()
The implementation here delegates to the wrapped Logger instance.
isWarnEnabled in interface org.apache.juli.logging.Logtrue if the wrapped logger isWarnEnabled, or false otherwise.public boolean isErrorEnabled()
The implementation here delegates to the wrapped Logger instance.
isErrorEnabled in interface org.apache.juli.logging.Logtrue if the wrapped logger isErrorEnabled, or false otherwise.public boolean isFatalEnabled()
The implementation here delegates to the isErrorEnabled method of the wrapped Logger instance, because
SLF4J has no FATAL level.
isFatalEnabled in interface org.apache.juli.logging.Logtrue if the wrapped logger isErrorEnabled, or false otherwise.public void trace(Object msg)
The implementation here converts the message to a string, and logs it as TRACE level using the wrapped
Logger instance.
trace in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringpublic void trace(Object msg, Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as TRACE
level, using the wrapped Logger instance.
trace in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringthrown - the throwable to logpublic void debug(Object msg)
The implementation here converts the message to a string, and logs it as DEBUG level using the wrapped
Logger instance.
debug in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringpublic void debug(Object msg, Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as DEBUG
level, using the wrapped Logger instance.
debug in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringthrown - the throwable to logpublic void info(Object msg)
The implementation here converts the message to a string, and logs it as INFO level using the wrapped
Logger instance.
info in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringpublic void info(Object msg, Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as INFO
level, using the wrapped Logger instance.
info in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringthrown - the throwable to logpublic void warn(Object msg)
The implementation here converts the message to a string, and logs it as WARN level using the wrapped
Logger instance.
warn in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringpublic void warn(Object msg, Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as WARN
level, using the wrapped Logger instance.
warn in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringthrown - the throwable to logpublic void error(Object msg)
The implementation here converts the message to a string, and logs it as ERROR level using the wrapped
Logger instance.
error in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringpublic void error(Object msg, Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as ERROR
level, using the wrapped Logger instance.
error in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringthrown - the throwable to logpublic void fatal(Object msg)
The implementation here converts the message to a string, and logs it as ERROR level using the wrapped
Logger instance, SLF4J has no FATAL level.
fatal in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringpublic void fatal(Object msg, Throwable thrown)
The implementation here converts the message to a string, and logs it along with the given throwable as ERROR
level, using the wrapped Logger instance, because SLF4J has no
FATAL level.
fatal in interface org.apache.juli.logging.Logmsg - the message to log, to be converted to Stringthrown - the throwable to logprotected Object readResolve() throws ObjectStreamException
SLF4JDelegatingLog logger of the same name, so that it properly
belong to the context of the applicable
LogManager.ObjectStreamException - actually never thrown by this implementation.Copyright © 2015–2017. All rights reserved.