Class Slf4jLogger

  • All Implemented Interfaces:
    Logger

    public class Slf4jLogger
    extends java.lang.Object
    implements Logger
    Implements Sonar logging facade on top of slf4j
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Slf4jLogger​(org.slf4j.Logger slf4jLogger)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void debug​(java.lang.String msg)
      Logs a DEBUG message.
      void debug​(java.lang.String msg, java.lang.Object arg)
      Logs an DEBUG parameterized message according to the specified format and argument.
      void debug​(java.lang.String msg, java.lang.Object... args)
      Logs an DEBUG parameterized message according to the specified format and arguments.
      void debug​(java.lang.String msg, java.lang.Object arg1, java.lang.Object arg2)
      Logs an DEBUG parameterized message according to the specified format and arguments.
      void error​(java.lang.String msg)
      Logs an ERROR level message.
      void error​(java.lang.String msg, java.lang.Object arg)
      Logs an ERROR parameterized message according to the specified format and argument.
      void error​(java.lang.String msg, java.lang.Object... args)
      Logs a ERROR parameterized message according to the specified format and arguments.
      void error​(java.lang.String msg, java.lang.Object arg1, java.lang.Object arg2)
      Logs a ERROR parameterized message according to the specified format and arguments.
      void error​(java.lang.String msg, java.lang.Throwable thrown)
      Logs an exception at the ERROR level with an accompanying message.
      LoggerLevel getLevel()  
      void info​(java.lang.String msg)
      Logs an INFO level message.
      void info​(java.lang.String msg, java.lang.Object arg)
      Logs an INFO parameterized message according to the specified format and argument.
      void info​(java.lang.String msg, java.lang.Object... args)
      Logs an INFO parameterized message according to the specified format and arguments.
      void info​(java.lang.String msg, java.lang.Object arg1, java.lang.Object arg2)
      Logs an INFO parameterized message according to the specified format and arguments.
      boolean isDebugEnabled()  
      boolean isTraceEnabled()  
      boolean setLevel​(LoggerLevel level)
      Attempt to change logger level.
      void trace​(java.lang.String msg)
      Logs a TRACE message.
      void trace​(java.lang.String msg, java.lang.Object arg)
      Logs an TRACE parameterized message according to the specified format and argument.
      void trace​(java.lang.String msg, java.lang.Object... args)
      Logs an TRACE parameterized message according to the specified format and arguments.
      void trace​(java.lang.String msg, java.lang.Object arg1, java.lang.Object arg2)
      Logs an TRACE parameterized message according to the specified format and arguments.
      void warn​(java.lang.String msg)
      Logs a WARN level message.
      void warn​(java.lang.String msg, java.lang.Object arg)
      Logs a WARN parameterized message according to the specified format and argument.
      void warn​(java.lang.String msg, java.lang.Object... args)
      Logs a WARN parameterized message according to the specified format and arguments.
      void warn​(java.lang.String msg, java.lang.Object arg1, java.lang.Object arg2)
      Logs a WARN parameterized message according to the specified format and arguments.
      void warn​(java.lang.String msg, java.lang.Throwable thrown)
      Logs an exception at the WARN level with an accompanying message.
      • Methods inherited from class java.lang.Object

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

      • Slf4jLogger

        protected Slf4jLogger​(org.slf4j.Logger slf4jLogger)
    • Method Detail

      • isTraceEnabled

        public boolean isTraceEnabled()
        Specified by:
        isTraceEnabled in interface Logger
      • trace

        public void trace​(java.lang.String msg)
        Description copied from interface: Logger
        Logs a TRACE message.

        TRACE messages must be valuable for diagnosing production problems. They must not be used for development debugging. They can significantly slow down performances. The standard use-case is logging of SQL and Elasticsearch requests.

        Specified by:
        trace in interface Logger
      • trace

        public void trace​(java.lang.String msg,
                          @Nullable
                          java.lang.Object arg)
        Description copied from interface: Logger
        Logs an TRACE parameterized message according to the specified format and argument. Example: trace("Value is {}", value)

        TRACE messages must be valuable for diagnosing production problems. They must not be used for development debugging. They can significantly slow down performances. The standard use-case is logging of SQL and Elasticsearch requests.

        Specified by:
        trace in interface Logger
      • trace

        public void trace​(java.lang.String msg,
                          @Nullable
                          java.lang.Object arg1,
                          @Nullable
                          java.lang.Object arg2)
        Description copied from interface: Logger
        Logs an TRACE parameterized message according to the specified format and arguments. Example: trace("Values are {} and {}", value1, value2)

        TRACE messages must be valuable for diagnosing production problems. They must not be used for development debugging. They can significantly slow down performances. The standard use-case is logging of SQL and Elasticsearch requests.

        Specified by:
        trace in interface Logger
      • trace

        public void trace​(java.lang.String msg,
                          java.lang.Object... args)
        Description copied from interface: Logger
        Logs an TRACE parameterized message according to the specified format and arguments. Example: trace("Values are {} and {}", value1, value2)

        TRACE messages must be valuable for diagnosing production problems. They must not be used for development debugging. They can significantly slow down performances. The standard use-case is logging of SQL and Elasticsearch requests.

        This variant incurs the hidden cost of creating an Object[] before invoking the method. The variants taking one and two arguments exist solely in order to avoid this hidden cost. See Logger.trace(String, Object) and Logger.trace(String, Object, Object)

        Specified by:
        trace in interface Logger
      • isDebugEnabled

        public boolean isDebugEnabled()
        Specified by:
        isDebugEnabled in interface Logger
      • debug

        public void debug​(java.lang.String msg)
        Description copied from interface: Logger
        Logs a DEBUG message.

        DEBUG messages must be valuable for diagnosing production problems. They must not be used for development debugging.

        Specified by:
        debug in interface Logger
      • debug

        public void debug​(java.lang.String msg,
                          @Nullable
                          java.lang.Object arg)
        Description copied from interface: Logger
        Logs an DEBUG parameterized message according to the specified format and argument. Example: debug("Value is {}", value)

        Debug messages must be valuable for diagnosing production problems. They must not be used for development debugging.

        Specified by:
        debug in interface Logger
      • debug

        public void debug​(java.lang.String msg,
                          @Nullable
                          java.lang.Object arg1,
                          @Nullable
                          java.lang.Object arg2)
        Description copied from interface: Logger
        Logs an DEBUG parameterized message according to the specified format and arguments. Example: debug("Values are {} and {}", value1, value2)

        Debug messages must be valuable for diagnosing production problems. They must not be used for development debugging.

        Specified by:
        debug in interface Logger
      • debug

        public void debug​(java.lang.String msg,
                          java.lang.Object... args)
        Description copied from interface: Logger
        Logs an DEBUG parameterized message according to the specified format and arguments. Example: debug("Values are {}, {} and {}", value1, value2, value3)

        Debug messages must be valuable for diagnosing production problems. They must not be used for development debugging. *

        This variant incurs the hidden cost of creating an Object[] before invoking the method. The variants taking one and two arguments exist solely in order to avoid this hidden cost. See Logger.debug(String, Object) and Logger.debug(String, Object, Object)

        Specified by:
        debug in interface Logger
      • info

        public void info​(java.lang.String msg)
        Description copied from interface: Logger
        Logs an INFO level message.
        Specified by:
        info in interface Logger
      • info

        public void info​(java.lang.String msg,
                         @Nullable
                         java.lang.Object arg)
        Description copied from interface: Logger
        Logs an INFO parameterized message according to the specified format and argument. Example: info("Value is {}", value)
        Specified by:
        info in interface Logger
      • info

        public void info​(java.lang.String msg,
                         @Nullable
                         java.lang.Object arg1,
                         @Nullable
                         java.lang.Object arg2)
        Description copied from interface: Logger
        Logs an INFO parameterized message according to the specified format and arguments. Example: info("Values are {} and {}", value1, value2)
        Specified by:
        info in interface Logger
      • info

        public void info​(java.lang.String msg,
                         java.lang.Object... args)
        Description copied from interface: Logger
        Logs an INFO parameterized message according to the specified format and arguments. Example: info("Values are {}, {} and {}", value1, value2, value3)

        This variant incurs the hidden cost of creating an Object[] before invoking the method. The variants taking one and two arguments exist solely in order to avoid this hidden cost. See Logger.info(String, Object) and Logger.info(String, Object, Object)

        Specified by:
        info in interface Logger
      • warn

        public void warn​(java.lang.String msg)
        Description copied from interface: Logger
        Logs a WARN level message.
        Specified by:
        warn in interface Logger
      • warn

        public void warn​(java.lang.String msg,
                         java.lang.Throwable thrown)
        Description copied from interface: Logger
        Logs an exception at the WARN level with an accompanying message.
        Specified by:
        warn in interface Logger
      • warn

        public void warn​(java.lang.String msg,
                         @Nullable
                         java.lang.Object arg)
        Description copied from interface: Logger
        Logs a WARN parameterized message according to the specified format and argument. Example: warn("Value is {}", value)
        Specified by:
        warn in interface Logger
      • warn

        public void warn​(java.lang.String msg,
                         @Nullable
                         java.lang.Object arg1,
                         @Nullable
                         java.lang.Object arg2)
        Description copied from interface: Logger
        Logs a WARN parameterized message according to the specified format and arguments. Example: warn("Values are {} and {}", value1, value2)
        Specified by:
        warn in interface Logger
      • warn

        public void warn​(java.lang.String msg,
                         java.lang.Object... args)
        Description copied from interface: Logger
        Logs a WARN parameterized message according to the specified format and arguments. Example: warn("Values are {}, {} and {}", value1, value2, value3)

        This variant incurs the hidden cost of creating an Object[] before invoking the method. The variants taking one and two arguments exist solely in order to avoid this hidden cost. See Logger.warn(String, Object) and Logger.warn(String, Object, Object)

        Specified by:
        warn in interface Logger
      • error

        public void error​(java.lang.String msg)
        Description copied from interface: Logger
        Logs an ERROR level message.
        Specified by:
        error in interface Logger
      • error

        public void error​(java.lang.String msg,
                          @Nullable
                          java.lang.Object arg)
        Description copied from interface: Logger
        Logs an ERROR parameterized message according to the specified format and argument. Example: error("Value is {}", value)
        Specified by:
        error in interface Logger
      • error

        public void error​(java.lang.String msg,
                          @Nullable
                          java.lang.Object arg1,
                          @Nullable
                          java.lang.Object arg2)
        Description copied from interface: Logger
        Logs a ERROR parameterized message according to the specified format and arguments. Example: error("Values are {} and {}", value1, value2)
        Specified by:
        error in interface Logger
      • error

        public void error​(java.lang.String msg,
                          java.lang.Object... args)
        Description copied from interface: Logger
        Logs a ERROR parameterized message according to the specified format and arguments. Example: error("Values are {}, {} and {}", value1, value2, value3)

        This variant incurs the hidden cost of creating an Object[] before invoking the method. The variants taking one and two arguments exist solely in order to avoid this hidden cost. See Logger.error(String, Object) and Logger.error(String, Object, Object)

        Specified by:
        error in interface Logger
      • error

        public void error​(java.lang.String msg,
                          java.lang.Throwable thrown)
        Description copied from interface: Logger
        Logs an exception at the ERROR level with an accompanying message.
        Specified by:
        error in interface Logger
      • setLevel

        public boolean setLevel​(LoggerLevel level)
        Description copied from interface: Logger
        Attempt to change logger level. Return true if it succeeded, false if the underlying logging facility does not allow to change level at runtime.

        This method must not be used to enable DEBUG or TRACE logs in tests. Use org.sonar.api.utils.log.LogTester.setLevel(LoggerLevel) from the test-fixtures instead.

        The standard use-case is to customize logging of embedded 3rd-party libraries.

        Specified by:
        setLevel in interface Logger