Class Logger

  • All Implemented Interfaces:

    
    public abstract class Logger
    
                        

    Standard logging methods.

    Author:

    Emil Ivov

    Boris Grozev

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public enum Logger.Category

      An enumeration of different categories for log messages.

    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Logger()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static Logger getLogger(Class<out Object> clazz) Create a logger for the specified class.
      static Logger getLogger(String name) Create a logger for the specified name.
      static Logger getLogger(Logger loggingDelegate, Logger levelDelegate) Creates a new Logger instance which performs logging through loggingDelegate and uses levelDelegate to configure its level.
      void logEntry() Logs an entry in the calling method.
      void logExit() Logs exiting the calling method
      boolean isTraceEnabled() Check if a message with a TRACE level would actually be logged by this logger.
      void trace(Object msg) Log a TRACE message.
      void trace(Object msg, Throwable t) Log a message, with associated Throwable information.
      boolean isDebugEnabled() Check if a message with a DEBUG level would actually be logged by this logger.
      void debug(Object msg) Log a DEBUG message.
      void debug(Object msg, Throwable t) Log a message, with associated Throwable information.
      boolean isInfoEnabled() Check if a message with an INFO level would actually be logged by this logger.
      void info(Object msg) Log a INFO message.
      void info(Object msg, Throwable t) Log a message, with associated Throwable information.
      boolean isWarnEnabled() Check if a message with a WARN level would actually be logged by this logger.
      void warn(Object msg) Log a WARN message.
      void warn(Object msg, Throwable t) Log a message, with associated Throwable information.
      void error(Object msg) Log a ERROR message.
      void error(Object msg, Throwable t) Log a message, with associated Throwable information.
      void fatal(Object msg) Log a FATAL message.
      void fatal(Object msg, Throwable t) Log a message, with associated Throwable information.
      void setLevelFatal() Set logging level for all handlers to FATAL
      void setLevelError() Set logging level for all handlers to ERROR
      void setLevelWarn() Set logging level for all handlers to WARNING
      void setLevelInfo() Set logging level for all handlers to INFO
      void setLevelDebug() Set logging level for all handlers to DEBUG
      void setLevelTrace() Set logging level for all handlers to TRACE
      void setLevelAll() Set logging level for all handlers to ALL (allow all log messages)
      void setLevelOff() Set logging level for all handlers to OFF (allow no log messages)
      void reset() Reinitialize the logging properties and reread the logging configuration.
      abstract void setLevel(Level level) Set logging level for all handlers to level
      abstract Level getLevel()
      abstract void log(Level level, Object msg) Logs a message at a given level, if that level is loggable according to the log level configured by this instance.
      abstract void log(Level level, Object msg, Throwable thrown) Logs a message at a given level, if that level is loggable according to the log level configured by this instance.
      void log(Level level, Logger.Category category, String msg) Logs a given message with and given category at a given level, if that level is loggable according to the log level configured by this instance.
      void log(Level level, Logger.Category category, String msg, Throwable thrown) Logs a given message with and given category at a given level, if that level is loggable according to the log level configured by this instance.
      void debug(Logger.Category category, String msg) Log a message with debug level.
      void debug(Logger.Category category, String msg, Throwable t) Log a message with debug level, with associated Throwable information.
      void error(Logger.Category category, String msg) Log a message with error level.
      void error(Logger.Category category, String msg, Throwable t) Log a message with error level, with associated Throwable information.
      void info(Logger.Category category, String msg, Throwable t) Log a message with info level, with associated Throwable information.
      void info(Logger.Category category, String msg) Log a message with info level.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Logger

        Logger()
    • Method Detail

      • getLogger

         static Logger getLogger(Class<out Object> clazz)

        Create a logger for the specified class.

        Parameters:
        clazz - The class for which to create a logger.
        Returns:

        a suitable Logger

      • getLogger

         static Logger getLogger(String name)

        Create a logger for the specified name.

        Returns:

        a suitable Logger

      • getLogger

         static Logger getLogger(Logger loggingDelegate, Logger levelDelegate)

        Creates a new Logger instance which performs logging through loggingDelegate and uses levelDelegate to configure its level.

        Parameters:
        loggingDelegate - the Logger used for logging.
        levelDelegate - the Logger used for configuring the log level.
      • isTraceEnabled

         boolean isTraceEnabled()

        Check if a message with a TRACE level would actually be logged by this logger.

        Returns:

        true if the TRACE level is currently being logged

      • trace

         void trace(Object msg)

        Log a TRACE message.

        If the logger is currently enabled for the TRACE message level then the given message is forwarded to all the registered output Handler objects.

        Parameters:
        msg - The message to log
      • trace

         void trace(Object msg, Throwable t)

        Log a message, with associated Throwable information.

        Parameters:
        msg - The message to log
        t - Throwable associated with log message.
      • isDebugEnabled

         boolean isDebugEnabled()

        Check if a message with a DEBUG level would actually be logged by this logger.

        Returns:

        true if the DEBUG level is currently being logged

      • debug

         void debug(Object msg)

        Log a DEBUG message.

        If the logger is currently enabled for the DEBUG message level then the given message is forwarded to all the registered output Handler objects.

        Parameters:
        msg - The message to log
      • debug

         void debug(Object msg, Throwable t)

        Log a message, with associated Throwable information.

        Parameters:
        msg - The message to log
        t - Throwable associated with log message.
      • isInfoEnabled

         boolean isInfoEnabled()

        Check if a message with an INFO level would actually be logged by this logger.

        Returns:

        true if the INFO level is currently being logged

      • info

         void info(Object msg)

        Log a INFO message.

        If the logger is currently enabled for the INFO message level then the given message is forwarded to all the registered output Handler objects.

        Parameters:
        msg - The message to log
      • info

         void info(Object msg, Throwable t)

        Log a message, with associated Throwable information.

        Parameters:
        msg - The message to log
        t - Throwable associated with log message.
      • isWarnEnabled

         boolean isWarnEnabled()

        Check if a message with a WARN level would actually be logged by this logger.

        Returns:

        true if the WARN level is currently being logged

      • warn

         void warn(Object msg)

        Log a WARN message.

        If the logger is currently enabled for the WARN message level then the given message is forwarded to all the registered output Handler objects.

        Parameters:
        msg - The message to log
      • warn

         void warn(Object msg, Throwable t)

        Log a message, with associated Throwable information.

        Parameters:
        msg - The message to log
        t - Throwable associated with log message.
      • error

         void error(Object msg)

        Log a ERROR message.

        If the logger is currently enabled for the ERROR message level then the given message is forwarded to all the registered output Handler objects.

        Parameters:
        msg - The message to log
      • error

         void error(Object msg, Throwable t)

        Log a message, with associated Throwable information.

        Parameters:
        msg - The message to log
        t - Throwable associated with log message.
      • fatal

         void fatal(Object msg)

        Log a FATAL message.

        If the logger is currently enabled for the FATAL message level then the given message is forwarded to all the registered output Handler objects.

        Parameters:
        msg - The message to log
      • fatal

         void fatal(Object msg, Throwable t)

        Log a message, with associated Throwable information.

        Parameters:
        msg - The message to log
        t - Throwable associated with log message.
      • setLevelFatal

         void setLevelFatal()

        Set logging level for all handlers to FATAL

      • setLevelError

         void setLevelError()

        Set logging level for all handlers to ERROR

      • setLevelWarn

         void setLevelWarn()

        Set logging level for all handlers to WARNING

      • setLevelInfo

         void setLevelInfo()

        Set logging level for all handlers to INFO

      • setLevelDebug

         void setLevelDebug()

        Set logging level for all handlers to DEBUG

      • setLevelTrace

         void setLevelTrace()

        Set logging level for all handlers to TRACE

      • setLevelAll

         void setLevelAll()

        Set logging level for all handlers to ALL (allow all log messages)

      • setLevelOff

         void setLevelOff()

        Set logging level for all handlers to OFF (allow no log messages)

      • reset

         void reset()

        Reinitialize the logging properties and reread the logging configuration.

        The same rules are used for locating the configuration properties as are used at startup. So if the properties containing the log dir locations have changed, we would read the new configuration.

      • setLevel

         abstract void setLevel(Level level)

        Set logging level for all handlers to level

        Parameters:
        level - the level to set for all logger handlers
      • log

         abstract void log(Level level, Object msg)

        Logs a message at a given level, if that level is loggable according to the log level configured by this instance.

        Parameters:
        level - the level at which to log the message.
        msg - the message to log.
      • log

         abstract void log(Level level, Object msg, Throwable thrown)

        Logs a message at a given level, if that level is loggable according to the log level configured by this instance.

        Parameters:
        level - the level at which to log the message.
        msg - the message to log.
        thrown - a Throwable associated with log message.
      • log

         void log(Level level, Logger.Category category, String msg)

        Logs a given message with and given category at a given level, if that level is loggable according to the log level configured by this instance. An identifier of the category in the form of CAT=name will will simply be prepended to the message.

        Parameters:
        level - the level at which to log the message.
        category - the category.
        msg - the message to log.
      • log

         void log(Level level, Logger.Category category, String msg, Throwable thrown)

        Logs a given message with and given category at a given level, if that level is loggable according to the log level configured by this instance. An identifier of the category in the form of CAT=name will will simply be prepended to the message.

        Parameters:
        level - the level at which to log the message.
        category - the category.
        msg - the message to log.
        thrown - a Throwable associated with log message.
      • debug

         void debug(Logger.Category category, String msg)

        Log a message with debug level. An identifier of the category in the form of CAT=name will will simply be prepended to the message.

        Parameters:
        category - the category.
        msg - The message to log
      • debug

         void debug(Logger.Category category, String msg, Throwable t)

        Log a message with debug level, with associated Throwable information. An identifier of the category in the form of CAT=name will will simply be prepended to the message.

        Parameters:
        category - the category.
        msg - The message to log
        t - Throwable associated with log message.
      • error

         void error(Logger.Category category, String msg)

        Log a message with error level. An identifier of the category in the form of CAT=name will will simply be prepended to the message.

        Parameters:
        category - the category.
        msg - The message to log
      • error

         void error(Logger.Category category, String msg, Throwable t)

        Log a message with error level, with associated Throwable information. An identifier of the category in the form of CAT=name will will simply be prepended to the message.

        Parameters:
        category - the category.
        msg - The message to log
        t - Throwable associated with log message.
      • info

         void info(Logger.Category category, String msg, Throwable t)

        Log a message with info level, with associated Throwable information. An identifier of the category in the form of CAT=name will will simply be prepended to the message.

        Parameters:
        category - the category.
        msg - The message to log
        t - Throwable associated with log message.
      • info

         void info(Logger.Category category, String msg)

        Log a message with info level. An identifier of the category in the form of CAT=name will will simply be prepended to the message.

        Parameters:
        category - the category.
        msg - The message to log