Class LogbackLogger


  • public class LogbackLogger
    extends LoggerAdapter
    Logger that redirect all Java logging events to logback framework * (using the sl4j API).
    • Level.ALL: org.slf4j.Level#ALL
    • Level.SEVERE: org.slf4j.Level#ERROR
    • Level.WARNING: org.slf4j.Level#WARN
    • Level.INFO: org.slf4j.Level#INFO}
    • Level.CONFIG: org.slf4j.Level#INFO with CONFIG marker.
    • Level.FINE: org.slf4j.Level#DEBUG
    • Level.FINER: org.slf4j.Level#TRACE
    • Level.FINEST: org.slf4j.Level#TRACE with FINEST marker.
    • Level.OFF: org.slf4j.Level#OFF
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Marker CONFIG
      Marker used to tag configuration Level.CONFIG messages, as checked with sl4j logger.isInfoEnabled(CONFIG).
      static Marker FATAL
      Marker used to tag configuration Logging.FATAL messages, as checked with sl4j logger.isErrorEnabled(FATAL).
      static Marker FINEST
      Marker used to tag configuration Level.FINEST messages, as checked with sl4j logger.isInfoEnabled(FINEST).
      Logger logger  
      • Fields inherited from class Logger

        global, GLOBAL_LOGGER_NAME
    • Constructor Summary

      Constructors 
      Constructor Description
      LogbackLogger​(String name, Logger logger)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void config​(String message)
      Logs an CONFIG message.
      void fine​(String message)
      Logs a FINE message.
      void finer​(String message)
      Logs a FINER message.
      void finest​(String message)
      Logs a FINEST message.
      Level getLevel()
      Returns the level for this logger.
      void info​(String message)
      Logs an INFO message.
      boolean isLoggable​(Level level)
      Returns true if the specified level is loggable.
      void log​(Level level, String message)
      Logs a record at the specified level.
      void log​(Level level, String message, Throwable thrown)
      Logs a record at the specified level, passing the provided throwable to slf4j api..
      void setLevel​(Level level)
      Sets the level for this logger.
      void severe​(String message)
      Logs a SEVERE message.
      void warning​(String message)
      Logs a WARNING message.
      • Methods inherited from class Logger

        config, fine, finer, finest, getAnonymousLogger, getAnonymousLogger, getFilter, getGlobal, getHandlers, getLogger, getLogger, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, info, log, log, logp, logp, logrb, logrb, logrb, logrb, setResourceBundle, severe, warning
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • FATAL

        public static final Marker FATAL
        Marker used to tag configuration Logging.FATAL messages, as checked with sl4j logger.isErrorEnabled(FATAL).
      • CONFIG

        public static final Marker CONFIG
        Marker used to tag configuration Level.CONFIG messages, as checked with sl4j logger.isInfoEnabled(CONFIG).
      • FINEST

        public static final Marker FINEST
        Marker used to tag configuration Level.FINEST messages, as checked with sl4j logger.isInfoEnabled(FINEST).
      • logger

        public Logger logger
    • Constructor Detail

      • LogbackLogger

        public LogbackLogger​(String name,
                             Logger logger)
    • Method Detail

      • setLevel

        public void setLevel​(Level level)
        Sets the level for this logger.

        Care is taken to use reflection to access logback-classic Level and Logger classes (to avoid hard runtime dependency when only the sl4j api is provided at runtime).

        Of logback-classic is unavailable level cannot be changed programmatically.

        Specified by:
        setLevel in class LoggerAdapter
        Parameters:
        level - Standard logging level used to configure logger
      • getLevel

        public Level getLevel()
        Description copied from class: LoggerAdapter
        Returns the level for this logger. Subclasses shall get this level from the external logging framework.
        Specified by:
        getLevel in class LoggerAdapter
      • isLoggable

        public boolean isLoggable​(Level level)
        Description copied from class: LoggerAdapter
        Returns true if the specified level is loggable.

        Implementation tip
        Given that Level.intValue() for all predefined levels are documented in the Level specification and are multiple of 100, given that integer divisions are rounded toward zero and given rule documented in this class javadoc, then logging levels can be efficiently mapped to predefined levels using switch statements as below. This statement has good chances to be compiled to the tableswitch bytecode rather than lookupswitch (see Compiling Switches in The Java Virtual Machine Specification).

        Specified by:
        isLoggable in class LoggerAdapter
      • severe

        public void severe​(String message)
        Description copied from class: LoggerAdapter
        Logs a SEVERE message.
        Specified by:
        severe in class LoggerAdapter
      • warning

        public void warning​(String message)
        Description copied from class: LoggerAdapter
        Logs a WARNING message.
        Specified by:
        warning in class LoggerAdapter
      • info

        public void info​(String message)
        Description copied from class: LoggerAdapter
        Logs an INFO message.
        Specified by:
        info in class LoggerAdapter
      • config

        public void config​(String message)
        Description copied from class: LoggerAdapter
        Logs an CONFIG message.
        Specified by:
        config in class LoggerAdapter
      • fine

        public void fine​(String message)
        Description copied from class: LoggerAdapter
        Logs a FINE message.
        Specified by:
        fine in class LoggerAdapter
      • finer

        public void finer​(String message)
        Description copied from class: LoggerAdapter
        Logs a FINER message.
        Specified by:
        finer in class LoggerAdapter
      • finest

        public void finest​(String message)
        Description copied from class: LoggerAdapter
        Logs a FINEST message.
        Specified by:
        finest in class LoggerAdapter
      • log

        public void log​(Level level,
                        String message,
                        Throwable thrown)
        Logs a record at the specified level, passing the provided throwable to slf4j api..
        Overrides:
        log in class LoggerAdapter