Interface Logger

  • All Known Implementing Classes:
    Slf4jLogger

    @Deprecated(since="9.15")
    public interface Logger
    Deprecated.
    since 9.15 in favor of Logger
    SonarQube plugins are not coupled with external logging libraries like SLF4J or Logback.

    Example:

     public class MyClass {
       private static final Logger LOGGER = Loggers.get("logger_name");
    
       public void doSomething() {
         LOGGER.info("something valuable for production environment");
         LOGGER.warn("message with arguments {} and {}", "foo", 42);
       }
     }
     

    Message arguments are defined with {}, but not with Formatter syntax.

    INFO, WARN and ERROR levels are always enabled. They can't be disabled by users. DEBUG and TRACE levels are enabled on demand with the property sonar.log.level.

    See org.sonar.api.utils.log.LogTester from the test-fixtures for testing facilities.

    Since:
    5.1
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      void debug​(java.lang.String msg)
      Deprecated.
      Logs a DEBUG message.
      void debug​(java.lang.String pattern, java.lang.Object arg)
      Deprecated.
      Logs an DEBUG parameterized message according to the specified format and argument.
      void debug​(java.lang.String msg, java.lang.Object... args)
      Deprecated.
      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)
      Deprecated.
      Logs an DEBUG parameterized message according to the specified format and arguments.
      default void debug​(java.util.function.Supplier<java.lang.String> msgSupplier)
      Deprecated.
      Logs a DEBUG message which is only to be constructed if the logging level is such that the message will actually be logged.
      void error​(java.lang.String msg)
      Deprecated.
      Logs an ERROR level message.
      void error​(java.lang.String msg, java.lang.Object arg)
      Deprecated.
      Logs an ERROR parameterized message according to the specified format and argument.
      void error​(java.lang.String msg, java.lang.Object... args)
      Deprecated.
      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)
      Deprecated.
      Logs a ERROR parameterized message according to the specified format and arguments.
      void error​(java.lang.String msg, java.lang.Throwable thrown)
      Deprecated.
      Logs an exception at the ERROR level with an accompanying message.
      LoggerLevel getLevel()
      Deprecated.
       
      void info​(java.lang.String msg)
      Deprecated.
      Logs an INFO level message.
      void info​(java.lang.String msg, java.lang.Object arg)
      Deprecated.
      Logs an INFO parameterized message according to the specified format and argument.
      void info​(java.lang.String msg, java.lang.Object... args)
      Deprecated.
      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)
      Deprecated.
      Logs an INFO parameterized message according to the specified format and arguments.
      boolean isDebugEnabled()
      Deprecated.
       
      boolean isTraceEnabled()
      Deprecated.
       
      default void log​(LoggerLevel level, java.lang.String msg)
      Deprecated.
       
      boolean setLevel​(LoggerLevel level)
      Deprecated.
      since 9.15 will always return false
      void trace​(java.lang.String msg)
      Deprecated.
      Logs a TRACE message.
      void trace​(java.lang.String pattern, java.lang.Object arg)
      Deprecated.
      Logs an TRACE parameterized message according to the specified format and argument.
      void trace​(java.lang.String msg, java.lang.Object... args)
      Deprecated.
      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)
      Deprecated.
      Logs an TRACE parameterized message according to the specified format and arguments.
      default void trace​(java.util.function.Supplier<java.lang.String> msgSupplier)
      Deprecated.
      Logs a TRACE message, which is only to be constructed if the logging level is such that the message will actually be logged.
      void warn​(java.lang.String msg)
      Deprecated.
      Logs a WARN level message.
      void warn​(java.lang.String msg, java.lang.Object arg)
      Deprecated.
      Logs a WARN parameterized message according to the specified format and argument.
      void warn​(java.lang.String msg, java.lang.Object... args)
      Deprecated.
      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)
      Deprecated.
      Logs a WARN parameterized message according to the specified format and arguments.
      void warn​(java.lang.String msg, java.lang.Throwable throwable)
      Deprecated.
      Logs an exception at the WARN level with an accompanying message.
    • Method Detail

      • isTraceEnabled

        boolean isTraceEnabled()
        Deprecated.
      • trace

        void trace​(java.lang.String msg)
        Deprecated.
        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.

      • trace

        default void trace​(java.util.function.Supplier<java.lang.String> msgSupplier)
        Deprecated.
        Logs a TRACE message, which is only to be constructed if the logging level is such that the message will actually be logged.

        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.

        Parameters:
        msgSupplier - A function, which when called, produces the desired log message
        Since:
        6.3
      • trace

        void trace​(java.lang.String pattern,
                   @Nullable
                   java.lang.Object arg)
        Deprecated.
        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.

      • trace

        void trace​(java.lang.String msg,
                   @Nullable
                   java.lang.Object arg1,
                   @Nullable
                   java.lang.Object arg2)
        Deprecated.
        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.

      • trace

        void trace​(java.lang.String msg,
                   java.lang.Object... args)
        Deprecated.
        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 trace(String, Object) and trace(String, Object, Object)

      • isDebugEnabled

        boolean isDebugEnabled()
        Deprecated.
      • debug

        void debug​(java.lang.String msg)
        Deprecated.
        Logs a DEBUG message.

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

      • debug

        default void debug​(java.util.function.Supplier<java.lang.String> msgSupplier)
        Deprecated.
        Logs a DEBUG message which is only to be constructed if the logging level is such that the message will actually be logged.

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

        Parameters:
        msgSupplier - A function, which when called, produces the desired log message
        Since:
        6.3
      • debug

        void debug​(java.lang.String pattern,
                   @Nullable
                   java.lang.Object arg)
        Deprecated.
        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.

      • debug

        void debug​(java.lang.String msg,
                   @Nullable
                   java.lang.Object arg1,
                   @Nullable
                   java.lang.Object arg2)
        Deprecated.
        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.

      • debug

        void debug​(java.lang.String msg,
                   java.lang.Object... args)
        Deprecated.
        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 debug(String, Object) and debug(String, Object, Object)

      • info

        void info​(java.lang.String msg)
        Deprecated.
        Logs an INFO level message.
      • info

        void info​(java.lang.String msg,
                  @Nullable
                  java.lang.Object arg)
        Deprecated.
        Logs an INFO parameterized message according to the specified format and argument. Example: info("Value is {}", value)
      • info

        void info​(java.lang.String msg,
                  @Nullable
                  java.lang.Object arg1,
                  @Nullable
                  java.lang.Object arg2)
        Deprecated.
        Logs an INFO parameterized message according to the specified format and arguments. Example: info("Values are {} and {}", value1, value2)
      • info

        void info​(java.lang.String msg,
                  java.lang.Object... args)
        Deprecated.
        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 info(String, Object) and info(String, Object, Object)

      • warn

        void warn​(java.lang.String msg)
        Deprecated.
        Logs a WARN level message.
      • warn

        void warn​(java.lang.String msg,
                  java.lang.Throwable throwable)
        Deprecated.
        Logs an exception at the WARN level with an accompanying message.
      • warn

        void warn​(java.lang.String msg,
                  @Nullable
                  java.lang.Object arg)
        Deprecated.
        Logs a WARN parameterized message according to the specified format and argument. Example: warn("Value is {}", value)
      • warn

        void warn​(java.lang.String msg,
                  @Nullable
                  java.lang.Object arg1,
                  @Nullable
                  java.lang.Object arg2)
        Deprecated.
        Logs a WARN parameterized message according to the specified format and arguments. Example: warn("Values are {} and {}", value1, value2)
      • warn

        void warn​(java.lang.String msg,
                  java.lang.Object... args)
        Deprecated.
        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 warn(String, Object) and warn(String, Object, Object)

      • error

        void error​(java.lang.String msg)
        Deprecated.
        Logs an ERROR level message.
      • error

        void error​(java.lang.String msg,
                   @Nullable
                   java.lang.Object arg)
        Deprecated.
        Logs an ERROR parameterized message according to the specified format and argument. Example: error("Value is {}", value)
      • error

        void error​(java.lang.String msg,
                   @Nullable
                   java.lang.Object arg1,
                   @Nullable
                   java.lang.Object arg2)
        Deprecated.
        Logs a ERROR parameterized message according to the specified format and arguments. Example: error("Values are {} and {}", value1, value2)
      • error

        void error​(java.lang.String msg,
                   java.lang.Object... args)
        Deprecated.
        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 error(String, Object) and error(String, Object, Object)

      • error

        void error​(java.lang.String msg,
                   java.lang.Throwable thrown)
        Deprecated.
        Logs an exception at the ERROR level with an accompanying message.
      • setLevel

        @Deprecated(since="9.15")
        boolean setLevel​(LoggerLevel level)
        Deprecated.
        since 9.15 will always return false
        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.

      • log

        default void log​(LoggerLevel level,
                         java.lang.String msg)
        Deprecated.
        Since:
        9.15