play
Class Logger

java.lang.Object
  extended by play.Logger

public class Logger
extends java.lang.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
static class Logger.ALogger
          Typical logger interface
 
Constructor Summary
Logger()
           
 
Method Summary
static void debug(java.lang.String message)
          Log a message with the DEBUG level.
static void debug(java.lang.String message, java.lang.Object... args)
          Log a message with the DEBUG level.
static void debug(java.lang.String message, java.lang.Throwable error)
          Log a message with the DEBUG level.
static void error(java.lang.String message)
          Log a message with the ERROR level.
static void error(java.lang.String message, java.lang.Object... args)
          Log a message with the ERROR level.
static void error(java.lang.String message, java.lang.Throwable error)
          Log a message with the ERROR level.
static void info(java.lang.String message)
          Log a message with the INFO level.
static void info(java.lang.String message, java.lang.Object... args)
          Log a message with the INFO level.
static void info(java.lang.String message, java.lang.Throwable error)
          Log a message with the INFO level.
static boolean isDebugEnabled()
          Returns true if the logger instance enabled for the DEBUG level?
static boolean isErrorEnabled()
          Returns true if the logger instance enabled for the ERROR level?
static boolean isInfoEnabled()
          Returns true if the logger instance enabled for the INFO level?
static boolean isTraceEnabled()
          Returns true if the logger instance enabled for the TRACE level?
static boolean isWarnEnabled()
          Returns true if the logger instance enabled for the WARN level?
static Logger.ALogger of(java.lang.Class<?> clazz)
          Obtain a logger instance.
static Logger.ALogger of(java.lang.String name)
          Obtain a logger instance.
static void trace(java.lang.String message)
          Log a message with the TRACE level.
static void trace(java.lang.String message, java.lang.Object... args)
          Log a message with the TRACE level.
static void trace(java.lang.String message, java.lang.Throwable error)
          Log a message with the TRACE level.
static org.slf4j.Logger underlying()
          Get the underlying application SLF4J logger.
static void warn(java.lang.String message)
          Log a message with the WARN level.
static void warn(java.lang.String message, java.lang.Object... args)
          Log a message with the WARN level.
static void warn(java.lang.String message, java.lang.Throwable error)
          Log a message with the WARN level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Logger

public Logger()
Method Detail

of

public static Logger.ALogger of(java.lang.String name)
Obtain a logger instance.

Parameters:
name - name of the logger
Returns:
a logger

of

public static Logger.ALogger of(java.lang.Class<?> clazz)
Obtain a logger instance.

Parameters:
clazz - a class whose name will be used as logger name
Returns:
a logger

underlying

public static org.slf4j.Logger underlying()
Get the underlying application SLF4J logger.


isTraceEnabled

public static boolean isTraceEnabled()
Returns true if the logger instance enabled for the TRACE level?


isDebugEnabled

public static boolean isDebugEnabled()
Returns true if the logger instance enabled for the DEBUG level?


isInfoEnabled

public static boolean isInfoEnabled()
Returns true if the logger instance enabled for the INFO level?


isWarnEnabled

public static boolean isWarnEnabled()
Returns true if the logger instance enabled for the WARN level?


isErrorEnabled

public static boolean isErrorEnabled()
Returns true if the logger instance enabled for the ERROR level?


trace

public static void trace(java.lang.String message)
Log a message with the TRACE level.

Parameters:
message - message to log

trace

public static void trace(java.lang.String message,
                         java.lang.Object... args)
Log a message with the TRACE level.

Parameters:
message - message to log
args - The arguments to apply to the message String

trace

public static void trace(java.lang.String message,
                         java.lang.Throwable error)
Log a message with the TRACE level.

Parameters:
message - message to log
error - associated exception

debug

public static void debug(java.lang.String message)
Log a message with the DEBUG level.

Parameters:
message - message to log

debug

public static void debug(java.lang.String message,
                         java.lang.Object... args)
Log a message with the DEBUG level.

Parameters:
message - message to log
args - The arguments to apply to the message String

debug

public static void debug(java.lang.String message,
                         java.lang.Throwable error)
Log a message with the DEBUG level.

Parameters:
message - message to log
error - associated exception

info

public static void info(java.lang.String message)
Log a message with the INFO level.

Parameters:
message - message to log

info

public static void info(java.lang.String message,
                        java.lang.Object... args)
Log a message with the INFO level.

Parameters:
message - message to log
args - The arguments to apply to the message string

info

public static void info(java.lang.String message,
                        java.lang.Throwable error)
Log a message with the INFO level.

Parameters:
message - message to log
error - associated exception

warn

public static void warn(java.lang.String message)
Log a message with the WARN level.

Parameters:
message - message to log

warn

public static void warn(java.lang.String message,
                        java.lang.Object... args)
Log a message with the WARN level.

Parameters:
message - message to log
args - The arguments to apply to the message string

warn

public static void warn(java.lang.String message,
                        java.lang.Throwable error)
Log a message with the WARN level.

Parameters:
message - message to log
error - associated exception

error

public static void error(java.lang.String message)
Log a message with the ERROR level.

Parameters:
message - message to log

error

public static void error(java.lang.String message,
                         java.lang.Object... args)
Log a message with the ERROR level.

Parameters:
message - message to log
args - The arguments to apply to the message string

error

public static void error(java.lang.String message,
                         java.lang.Throwable error)
Log a message with the ERROR level.

Parameters:
message - message to log
error - associated exception