Package play
Class Logger
- Object
-
- play.Logger
-
public class Logger extends Object
High level API for logging operations.Example, logging with the default application logger:
Logger.info("Hello!");Example, logging with a custom logger:Logger.of("my.logger").info("Hello!")Each of the logging methods is overloaded to be able to take an array of arguments. These are formatted into the message String, replacing occurrences of '{}'. For example:Logger.info("A {} request was received at {}", request.method(), request.uri());This might print out:A POST request was received at /api/items
This saves on the cost of String construction when logging is turned off.This API is intended as a simple logging API to meet 99% percent of the most common logging needs with minimal code overhead. For more complex needs, the underlying() methods may be used to get the underlying SLF4J logger, or SLF4J may be used directly.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLogger.ALoggerTypical logger interface
-
Constructor Summary
Constructors Constructor Description Logger()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voiddebug(String message)Deprecated.Deprecated as of 2.7.0.static voiddebug(String message, Object... args)Deprecated.Deprecated as of 2.7.0.static voiddebug(String message, Throwable error)Deprecated.Deprecated as of 2.7.0.static voiddebug(String message, Supplier<?>... args)Deprecated.Deprecated as of 2.7.0.static voiddebug(Supplier<String> msgSupplier)Deprecated.Deprecated as of 2.7.0.static voiderror(String message)Deprecated.Deprecated as of 2.7.0.static voiderror(String message, Object... args)Deprecated.Deprecated as of 2.7.0.static voiderror(String message, Throwable error)Deprecated.Deprecated as of 2.7.0.static voiderror(String message, Supplier<?> args)Deprecated.Deprecated as of 2.7.0.static voiderror(Supplier<String> msgSupplier)Deprecated.Deprecated as of 2.7.0.static voidinfo(String message)Deprecated.Deprecated as of 2.7.0.static voidinfo(String message, Object... args)Deprecated.Deprecated as of 2.7.0.static voidinfo(String message, Throwable error)Deprecated.Deprecated as of 2.7.0.static voidinfo(String message, Supplier<?>... args)Deprecated.Deprecated as of 2.7.0.static voidinfo(Supplier<String> msgSupplier)Deprecated.Deprecated as of 2.7.0.static booleanisDebugEnabled()Deprecated.Deprecated as of 2.7.0.static booleanisErrorEnabled()Deprecated.Deprecated as of 2.7.0.static booleanisInfoEnabled()Deprecated.Deprecated as of 2.7.0.static booleanisTraceEnabled()Deprecated.Deprecated as of 2.7.0.static booleanisWarnEnabled()Deprecated.Deprecated as of 2.7.0.static Logger.ALoggerof(Class<?> clazz)Obtain a logger instance.static Logger.ALoggerof(String name)Obtain a logger instance.static voidtrace(String message)Deprecated.Deprecated as of 2.7.0.static voidtrace(String message, Object... args)Deprecated.Deprecated as of 2.7.0.static voidtrace(String message, Throwable error)Deprecated.Deprecated as of 2.7.0.static voidtrace(String message, Supplier<?>... args)Deprecated.Deprecated as of 2.7.0.static voidtrace(Supplier<String> msgSupplier)Deprecated.Deprecated as of 2.7.0.static org.slf4j.Loggerunderlying()Deprecated.Deprecated as of 2.7.0.static voidwarn(String message)Deprecated.Deprecated as of 2.7.0.static voidwarn(String message, Object... args)Deprecated.Deprecated as of 2.7.0.static voidwarn(String message, Throwable error)Deprecated.Deprecated as of 2.7.0.static voidwarn(String message, Supplier<?>... args)Deprecated.Deprecated as of 2.7.0.static voidwarn(Supplier<String> msgSupplier)Deprecated.Deprecated as of 2.7.0.
-
-
-
Method Detail
-
of
public static Logger.ALogger of(String name)
Obtain a logger instance.- Parameters:
name- name of the logger- Returns:
- a logger
-
of
public static Logger.ALogger of(Class<?> clazz)
Obtain a logger instance.- Parameters:
clazz- a class whose name will be used as logger name- Returns:
- a logger
-
underlying
@Deprecated public static org.slf4j.Logger underlying()
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Get the underlying application SLF4J logger.- Returns:
- the underlying logger
-
isTraceEnabled
@Deprecated public static boolean isTraceEnabled()
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Returnstrueif the logger instance enabled for the TRACE level?- Returns:
trueif the logger instance enabled for the TRACE level?
-
isDebugEnabled
@Deprecated public static boolean isDebugEnabled()
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Returnstrueif the logger instance enabled for the DEBUG level?- Returns:
trueif the logger instance enabled for the DEBUG level?
-
isInfoEnabled
@Deprecated public static boolean isInfoEnabled()
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Returnstrueif the logger instance enabled for the INFO level?- Returns:
trueif the logger instance enabled for the INFO level?
-
isWarnEnabled
@Deprecated public static boolean isWarnEnabled()
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Returnstrueif the logger instance enabled for the WARN level?- Returns:
trueif the logger instance enabled for the WARN level?
-
isErrorEnabled
@Deprecated public static boolean isErrorEnabled()
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Returnstrueif the logger instance enabled for the ERROR level?- Returns:
trueif the logger instance enabled for the ERROR level?
-
trace
@Deprecated public static void trace(String message)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the TRACE level.- Parameters:
message- message to log
-
trace
@Deprecated public static void trace(Supplier<String> msgSupplier)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the TRACE level.- Parameters:
msgSupplier-Supplierthat contains message to log
-
trace
@Deprecated public static void trace(String message, Object... args)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the TRACE level.- Parameters:
message- message to logargs- The arguments to apply to the message String
-
trace
@Deprecated public static void trace(String message, Supplier<?>... args)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the TRACE level.- Parameters:
message- message to logargs- Suppliers that contain arguments to apply to the message String
-
trace
@Deprecated public static void trace(String message, Throwable error)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the TRACE level.- Parameters:
message- message to logerror- associated exception
-
debug
@Deprecated public static void debug(String message)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the DEBUG level.- Parameters:
message- message to log
-
debug
@Deprecated public static void debug(Supplier<String> msgSupplier)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the DEBUG level.- Parameters:
msgSupplier-Supplierthat contains message to log
-
debug
@Deprecated public static void debug(String message, Object... args)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the DEBUG level.- Parameters:
message- message to logargs- The arguments to apply to the message String
-
debug
@Deprecated public static void debug(String message, Supplier<?>... args)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the DEBUG level.- Parameters:
message- message to logargs- Suppliers that contain arguments to apply to the message String
-
debug
@Deprecated public static void debug(String message, Throwable error)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the DEBUG level.- Parameters:
message- message to logerror- associated exception
-
info
@Deprecated public static void info(String message)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the INFO level.- Parameters:
message- message to log
-
info
@Deprecated public static void info(Supplier<String> msgSupplier)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the INFO level.- Parameters:
msgSupplier-Supplierthat contains message to log
-
info
@Deprecated public static void info(String message, Object... args)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the INFO level.- Parameters:
message- message to logargs- The arguments to apply to the message string
-
info
@Deprecated public static void info(String message, Supplier<?>... args)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the INFO level.- Parameters:
message- message to logargs- Suppliers that contain arguments to apply to the message String
-
info
@Deprecated public static void info(String message, Throwable error)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the INFO level.- Parameters:
message- message to logerror- associated exception
-
warn
@Deprecated public static void warn(String message)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the WARN level.- Parameters:
message- message to log
-
warn
@Deprecated public static void warn(Supplier<String> msgSupplier)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the WARN level.- Parameters:
msgSupplier-Supplierthat contains message to log
-
warn
@Deprecated public static void warn(String message, Object... args)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the WARN level.- Parameters:
message- message to logargs- The arguments to apply to the message string
-
warn
@Deprecated public static void warn(String message, Supplier<?>... args)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the WARN level.- Parameters:
message- message to logargs- Suppliers that contain arguments to apply to the message String
-
warn
@Deprecated public static void warn(String message, Throwable error)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the WARN level.- Parameters:
message- message to logerror- associated exception
-
error
@Deprecated public static void error(String message)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the ERROR level.- Parameters:
message- message to log
-
error
@Deprecated public static void error(Supplier<String> msgSupplier)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the ERROR level.- Parameters:
msgSupplier-Supplierthat contains message to log
-
error
@Deprecated public static void error(String message, Object... args)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the ERROR level.- Parameters:
message- message to logargs- The arguments to apply to the message string
-
error
@Deprecated public static void error(String message, Supplier<?> args)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the ERROR level.- Parameters:
message- message to logargs- Suppliers that contain arguments to apply to the message String
-
error
@Deprecated public static void error(String message, Throwable error)
Deprecated.Deprecated as of 2.7.0. Create an instance ofLogger.ALoggerviaof(String)/of(Class)and use the same-named method. Or use SLF4J directly.Log a message with the ERROR level.- Parameters:
message- message to logerror- associated exception
-
-