public interface Logger
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 LogTester
for testing facilities.Modifier and Type | Method and Description |
---|---|
void |
debug(String msg)
Logs a DEBUG message.
|
void |
debug(String msg,
Object... args) |
void |
debug(String pattern,
Object arg) |
void |
debug(String msg,
Object arg1,
Object arg2) |
void |
error(String msg)
Logs an ERROR level message.
|
void |
error(String msg,
Object... args) |
void |
error(String msg,
Object arg) |
void |
error(String msg,
Object arg1,
Object arg2) |
void |
error(String msg,
Throwable thrown) |
void |
info(String msg)
Logs an INFO level message.
|
void |
info(String msg,
Object... args) |
void |
info(String msg,
Object arg) |
void |
info(String msg,
Object arg1,
Object arg2) |
boolean |
isDebugEnabled() |
boolean |
isTraceEnabled() |
boolean |
setLevel(LoggerLevel level)
Attempt to change logger level.
|
void |
trace(String msg)
Logs a TRACE message.
|
void |
trace(String msg,
Object... args) |
void |
trace(String pattern,
Object arg) |
void |
trace(String msg,
Object arg1,
Object arg2) |
void |
warn(String msg)
Logs a WARN level message.
|
void |
warn(String msg,
Object... args) |
void |
warn(String msg,
Object arg) |
void |
warn(String msg,
Object arg1,
Object arg2) |
boolean isTraceEnabled()
void trace(String msg)
void trace(String pattern, @Nullable Object arg)
trace(String)
void trace(String msg, Object... args)
trace(String)
boolean isDebugEnabled()
void debug(String msg)
void debug(String pattern, @Nullable Object arg)
debug(String)
void debug(String msg, Object... args)
debug(String)
void info(String msg, @Nullable Object arg)
info(String)
void info(String msg, Object... args)
info(String)
void warn(String msg, @Nullable Object arg)
warn(String)
void warn(String msg, Object... args)
warn(String)
void error(String msg, @Nullable Object arg)
error(String)
void error(String msg, Object... args)
error(String)
void error(String msg, Throwable thrown)
error(String)
boolean setLevel(LoggerLevel level)
LogTester.setLevel(LoggerLevel)
instead.
The standard use-case is to customize logging of embedded 3rd-party
libraries.Copyright © 2009–2015 SonarSource. All rights reserved.