Class LogbackLogger

    • 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
      • 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