Class Logger


  • public class Logger
    extends Object
    • Method Detail

      • get

        public static Logger get​(Class<?> clazz)
        Gets a logger named after a class' fully qualified name.
        Parameters:
        clazz - the class
        Returns:
        the named logger
      • get

        public static Logger get​(String name)
        Gets a named logger
        Parameters:
        name - the name of the logger
        Returns:
        the named logger
      • verbose

        public void verbose​(Throwable exception,
                            String message)
        Logs a message at VERBOSE level.
        Parameters:
        exception - an exception associated with the verbose message being logged
        message - a literal message to log
      • verbose

        public void verbose​(String message)
        Logs a message at VERBOSE level.
        Parameters:
        message - a literal message to log
      • verbose

        public void verbose​(String format,
                            Object... args)
        Logs a message at VERBOSE level.
        Usage example:
            logger.verbose("value is %s (%d ms)", value, time);
         
        If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
        Parameters:
        format - a format string compatible with String.format()
        args - arguments for the format string
      • verbose

        public void verbose​(@Nullable
                            Throwable exception,
                            String format,
                            Object... args)
        Logs a message at VERBOSE level.
        Usage example:
            logger.verbose(e, "value is %s (%d ms)", value, time);
         
        If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
        Parameters:
        exception - an exception associated with the verbose message being logged
        format - a format string compatible with String.format()
        args - arguments for the format string
      • debug

        public void debug​(Throwable exception,
                          String message)
        Logs a message at DEBUG level.
        Parameters:
        exception - an exception associated with the debug message being logged
        message - a literal message to log
      • debug

        public void debug​(String message)
        Logs a message at DEBUG level.
        Parameters:
        message - a literal message to log
      • debug

        public void debug​(String format,
                          Object... args)
        Logs a message at DEBUG level.
        Usage example:
            logger.debug("value is %s (%d ms)", value, time);
         
        If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
        Parameters:
        format - a format string compatible with String.format()
        args - arguments for the format string
      • debug

        public void debug​(@Nullable
                          Throwable exception,
                          String format,
                          Object... args)
        Logs a message at DEBUG level.
        Usage example:
            logger.debug(e, "value is %s (%d ms)", value, time);
         
        If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
        Parameters:
        exception - an exception associated with the debug message being logged
        format - a format string compatible with String.format()
        args - arguments for the format string
      • info

        public void info​(String message)
        Logs a message at INFO level.
        Parameters:
        message - a literal message to log
      • info

        public void info​(@Nullable
                         Throwable exception,
                         String format,
                         Object... args)
        Logs a message at INFO level.
        Usage example:
            logger.info("value is %s (%d ms)", value, time);
         
        If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
        Parameters:
        exception - an exception associated with the warning being logged
        format - a format string compatible with String.format()
        args - arguments for the format string
      • info

        public void info​(String format,
                         Object... args)
        Logs a message at INFO level.
        Parameters:
        format - a format string compatible with String.format()
        args - arguments for the format string
      • warn

        public void warn​(Throwable exception,
                         String message)
        Logs a message at WARN level.
        Parameters:
        exception - an exception associated with the warning being logged
        message - a literal message to log
      • warn

        public void warn​(String message)
        Logs a message at WARN level.
        Parameters:
        message - a literal message to log
      • warn

        public void warn​(@Nullable
                         Throwable exception,
                         String format,
                         Object... args)
        Logs a message at WARN level.
        Usage example:
            logger.warn(e, "something bad happened when connecting to %s:%d", host, port);
         
        If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
        Parameters:
        exception - an exception associated with the warning being logged
        format - a format string compatible with String.format()
        args - arguments for the format string
      • warn

        public void warn​(String format,
                         Object... args)
        Logs a message at WARN level.
        Usage example:
            logger.warn("something bad happened when connecting to %s:%d", host, port);
         
        If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
        Parameters:
        format - a format string compatible with String.format()
        args - arguments for the format string
      • error

        public void error​(Throwable exception,
                          String message)
        Logs a message at ERROR level.
        Parameters:
        exception - an exception associated with the error being logged
        message - a literal message to log
      • error

        public void error​(String message)
        Logs a message at ERROR level.
        Parameters:
        message - a literal message to log
      • error

        public void error​(@Nullable
                          Throwable exception,
                          String format,
                          Object... args)
        Logs a message at ERROR level.
        Usage example:
            logger.error(e, "something really bad happened when connecting to %s:%d", host, port);
         
        If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
        Parameters:
        exception - an exception associated with the error being logged
        format - a format string compatible with String.format()
        args - arguments for the format string
      • error

        public void error​(Throwable exception)
        Logs a message at ERROR level. The value of exception.getMessage() will be used as the log message.
        Usage example:
            logger.error(e);
         
        Parameters:
        exception - an exception associated with the error being logged
      • error

        public void error​(String format,
                          Object... args)
        Logs a message at ERROR level.
        Usage example:
            logger.error("something really bad happened when connecting to %s:%d", host, port);
         
        If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
        Parameters:
        format - a format string compatible with String.format()
        args - arguments for the format string
      • isVerboseEnabled

        public boolean isVerboseEnabled()
      • isDebugEnabled

        public boolean isDebugEnabled()
      • getLevel

        public Level getLevel()
      • setLevel

        public void setLevel​(Level newLevel)
      • isLoggable

        public boolean isLoggable​(Level level)
      • addHandler

        public void addHandler​(Handler handler)
      • getHandlers

        public Handler[] getHandlers()