import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Wombat {
final static Logger logger = LoggerFactory.getLogger(Wombat.class);
Integer t;
Integer oldT;
public void setTemperature(Integer temperature) {
oldT = t;
t = temperature;
logger.debug("Temperature set to {}. Old temperature was {}.", t, oldT);
if (temperature.intValue() > 50) {
logger.info("Temperature has risen above 50 degrees.");
}
}
}
Note that version 2.0 of the SLF4J API introduces a fluent api, the most significant API change to occur in the last 20 years.
Be sure to read the FAQ entry relating to parameterized logging. Note that logging statements can be parameterized in presence of an exception/throwable.
Once you are comfortable using loggers, i.e. instances of this interface, consider using MDC as well as Markers.
| Modifier and Type | Field and Description |
|---|---|
| public static final String | ROOT_LOGGER_NAME
Case-insensitive String constant used to retrieve the name of the root logger. |
| Modifier and Type | Method and Description |
|---|---|
| public default LoggingEventBuilder | Returns: LoggingEventBuilder instance as appropriate for level DEBUGEntry point for fluent-logging for |
| public default LoggingEventBuilder | Returns: LoggingEventBuilder instance as appropriate for level ERROREntry point for fluent-logging for |
| public default LoggingEventBuilder | Returns: LoggingEventBuilder instance as appropriate for level INFOEntry point for fluent-logging for |
| public default LoggingEventBuilder | Returns: a newLoggingEventBuilder instance as appropriate for this loggerdesired level for the event builder level)Make a new |
| public default LoggingEventBuilder | Returns: LoggingEventBuilder instance as appropriate for level TRACEEntry point for fluent-logging for |
| public default LoggingEventBuilder | Returns: LoggingEventBuilder instance as appropriate for level WARNEntry point for fluent-logging for |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | debug(Marker
the marker data specific to this log statement marker, String the format string format, Object the argument arg)This method is similar to |
| public void | |
| public void | debug(Marker
the marker data specific to this log statement marker, String the format string format, Object... a list of 3 or more arguments arguments)This method is similar to |
| public void | debug(Marker
the marker data specific to this log statement marker, String the message accompanying the exception msg, Throwable the exception (throwable) to log t)This method is similar to |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | error(Marker
the marker data specific to this log statement marker, String the format string format, Object the argument arg)This method is similar to |
| public void | |
| public void | error(Marker
the marker data specific to this log statement marker, String the format string format, Object... a list of 3 or more arguments arguments)This method is similar to |
| public void | error(Marker
the marker data specific to this log statement marker, String the message accompanying the exception msg, Throwable the exception (throwable) to log t)This method is similar to |
| public String | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | info(Marker
the marker data specific to this log statement marker, String the format string format, Object the argument arg)This method is similar to |
| public void | |
| public void | info(Marker
the marker data specific to this log statement marker, String the format string format, Object... a list of 3 or more arguments arguments)This method is similar to |
| public void | info(Marker
the marker data for this log statement marker, String the message accompanying the exception msg, Throwable the exception (throwable) to log t)This method is similar to |
| public boolean | Returns: True if this Logger is enabled for the DEBUG level, false otherwise.Is the logger instance enabled for the DEBUG level? |
| public boolean | Returns: True if this Logger is enabled for the DEBUG level, false otherwise.The marker data to take into consideration marker)Similar to |
| public default boolean | Returns: true if enabled, false otherwise.Returns whether this Logger is enabled for a given |
| public boolean | Returns: True if this Logger is enabled for the ERROR level, false otherwise.Is the logger instance enabled for the ERROR level? |
| public boolean | Returns: True if this Logger is enabled for the ERROR level, false otherwise.The marker data to take into consideration marker)Similar to |
| public boolean | Returns: True if this Logger is enabled for the INFO level, false otherwise.Is the logger instance enabled for the INFO level? |
| public boolean | Returns: true if this Logger is enabled for the INFO level, false otherwise.The marker data to take into consideration marker)Similar to |
| public boolean | Returns: True if this Logger is enabled for the TRACE level, false otherwise.Is the logger instance enabled for the TRACE level? |
| public boolean | Returns: True if this Logger is enabled for the TRACE level, false otherwise.The marker data to take into consideration marker)Similar to |
| public boolean | Returns: True if this Logger is enabled for the WARN level, false otherwise.Is the logger instance enabled for the WARN level? |
| public boolean | Returns: True if this Logger is enabled for the WARN level, false otherwise.The marker data to take into consideration marker)Similar to |
| public default LoggingEventBuilder | Returns: a newLoggingEventBuilder instance as appropriate for this loggerdesired level for the event builder level)Make a new |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | trace(Marker
the marker data specific to this log statement marker, String the format string format, Object the argument arg)This method is similar to |
| public void | |
| public void | trace(Marker
the marker data specific to this log statement marker, String the format string format, Object... an array of arguments argArray)This method is similar to |
| public void | trace(Marker
the marker data specific to this log statement marker, String the message accompanying the exception msg, Throwable the exception (throwable) to log t)This method is similar to |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | warn(Marker
the marker data specific to this log statement marker, String the format string format, Object the argument arg)This method is similar to |
| public void | |
| public void | warn(Marker
the marker data specific to this log statement marker, String the format string format, Object... a list of 3 or more arguments arguments)This method is similar to |
| public void | warn(Marker
the marker data for this log statement marker, String the message accompanying the exception msg, Throwable the exception (throwable) to log t)This method is similar to |