Interface Logger
-
- All Known Implementing Classes:
Slf4jLogger
@Deprecated(since="9.15") public interface LoggerDeprecated.since 9.15 in favor ofLoggerSonarQube 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 withFormattersyntax.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.LogTesterfrom 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 voiddebug(java.lang.String msg)Deprecated.Logs a DEBUG message.voiddebug(java.lang.String pattern, java.lang.Object arg)Deprecated.Logs an DEBUG parameterized message according to the specified format and argument.voiddebug(java.lang.String msg, java.lang.Object... args)Deprecated.Logs an DEBUG parameterized message according to the specified format and arguments.voiddebug(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 voiddebug(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.voiderror(java.lang.String msg)Deprecated.Logs an ERROR level message.voiderror(java.lang.String msg, java.lang.Object arg)Deprecated.Logs an ERROR parameterized message according to the specified format and argument.voiderror(java.lang.String msg, java.lang.Object... args)Deprecated.Logs a ERROR parameterized message according to the specified format and arguments.voiderror(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.voiderror(java.lang.String msg, java.lang.Throwable thrown)Deprecated.Logs an exception at the ERROR level with an accompanying message.LoggerLevelgetLevel()Deprecated.voidinfo(java.lang.String msg)Deprecated.Logs an INFO level message.voidinfo(java.lang.String msg, java.lang.Object arg)Deprecated.Logs an INFO parameterized message according to the specified format and argument.voidinfo(java.lang.String msg, java.lang.Object... args)Deprecated.Logs an INFO parameterized message according to the specified format and arguments.voidinfo(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.booleanisDebugEnabled()Deprecated.booleanisTraceEnabled()Deprecated.default voidlog(LoggerLevel level, java.lang.String msg)Deprecated.booleansetLevel(LoggerLevel level)Deprecated.since 9.15 will always return falsevoidtrace(java.lang.String msg)Deprecated.Logs a TRACE message.voidtrace(java.lang.String pattern, java.lang.Object arg)Deprecated.Logs an TRACE parameterized message according to the specified format and argument.voidtrace(java.lang.String msg, java.lang.Object... args)Deprecated.Logs an TRACE parameterized message according to the specified format and arguments.voidtrace(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 voidtrace(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.voidwarn(java.lang.String msg)Deprecated.Logs a WARN level message.voidwarn(java.lang.String msg, java.lang.Object arg)Deprecated.Logs a WARN parameterized message according to the specified format and argument.voidwarn(java.lang.String msg, java.lang.Object... args)Deprecated.Logs a WARN parameterized message according to the specified format and arguments.voidwarn(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.voidwarn(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)andtrace(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)anddebug(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)andinfo(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)andwarn(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)anderror(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 falseAttempt 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.
-
getLevel
LoggerLevel getLevel()
Deprecated.
-
log
default void log(LoggerLevel level, java.lang.String msg)
Deprecated.- Since:
- 9.15
-
-