public class Logger extends Object
Modifier and Type | Method and Description |
---|---|
void |
addHandler(Handler handler) |
void |
debug(String message)
Logs a message at DEBUG level.
|
void |
debug(String format,
Object... args)
Logs a message at DEBUG level.
|
void |
debug(Throwable exception,
String message)
Logs a message at DEBUG level.
|
void |
debug(Throwable exception,
String format,
Object... args)
Logs a message at DEBUG level.
|
void |
error(String message)
Logs a message at ERROR level.
|
void |
error(String format,
Object... args)
Logs a message at ERROR level.
|
void |
error(Throwable exception)
Logs a message at ERROR level.
|
void |
error(Throwable exception,
String message)
Logs a message at ERROR level.
|
void |
error(Throwable exception,
String format,
Object... args)
Logs a message at ERROR level.
|
static Logger |
get(Class<?> clazz)
Gets a logger named after a class' fully qualified name.
|
static Logger |
get(String name)
Gets a named logger
|
Handler[] |
getHandlers() |
Level |
getLevel() |
void |
info(String message)
Logs a message at INFO level.
|
void |
info(String format,
Object... args)
Logs a message at INFO level.
|
void |
info(Throwable exception,
String format,
Object... args)
Logs a message at INFO level.
|
boolean |
isDebugEnabled() |
boolean |
isLoggable(Level level) |
boolean |
isVerboseEnabled() |
void |
setLevel(Level newLevel) |
void |
verbose(String message)
Logs a message at VERBOSE level.
|
void |
verbose(String format,
Object... args)
Logs a message at VERBOSE level.
|
void |
verbose(Throwable exception,
String message)
Logs a message at VERBOSE level.
|
void |
verbose(Throwable exception,
String format,
Object... args)
Logs a message at VERBOSE level.
|
void |
warn(String message)
Logs a message at WARN level.
|
void |
warn(String format,
Object... args)
Logs a message at WARN level.
|
void |
warn(Throwable exception,
String message)
Logs a message at WARN level.
|
void |
warn(Throwable exception,
String format,
Object... args)
Logs a message at WARN level.
|
public static Logger get(Class<?> clazz)
clazz
- the classpublic static Logger get(String name)
name
- the name of the loggerpublic void verbose(Throwable exception, String message)
exception
- an exception associated with the verbose message being loggedmessage
- a literal message to logpublic void verbose(String message)
message
- a literal message to logpublic void verbose(String format, Object... args)
logger.verbose("value is %s (%d ms)", value, time);If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
format
- a format string compatible with String.format()args
- arguments for the format stringpublic void verbose(@Nullable Throwable exception, String format, Object... args)
logger.verbose(e, "value is %s (%d ms)", value, time);If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
exception
- an exception associated with the verbose message being loggedformat
- a format string compatible with String.format()args
- arguments for the format stringpublic void debug(Throwable exception, String message)
exception
- an exception associated with the debug message being loggedmessage
- a literal message to logpublic void debug(String message)
message
- a literal message to logpublic void debug(String format, Object... args)
logger.debug("value is %s (%d ms)", value, time);If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
format
- a format string compatible with String.format()args
- arguments for the format stringpublic void debug(@Nullable Throwable exception, String format, Object... args)
logger.debug(e, "value is %s (%d ms)", value, time);If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
exception
- an exception associated with the debug message being loggedformat
- a format string compatible with String.format()args
- arguments for the format stringpublic void info(String message)
message
- a literal message to logpublic void info(@Nullable Throwable exception, String format, Object... args)
logger.info("value is %s (%d ms)", value, time);If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
exception
- an exception associated with the warning being loggedformat
- a format string compatible with String.format()args
- arguments for the format stringpublic void info(String format, Object... args)
format
- a format string compatible with String.format()args
- arguments for the format stringpublic void warn(Throwable exception, String message)
exception
- an exception associated with the warning being loggedmessage
- a literal message to logpublic void warn(String message)
message
- a literal message to logpublic void warn(@Nullable Throwable exception, String format, Object... args)
logger.warn(e, "something bad happened when connecting to %s:%d", host, port);If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
exception
- an exception associated with the warning being loggedformat
- a format string compatible with String.format()args
- arguments for the format stringpublic void warn(String format, Object... args)
logger.warn("something bad happened when connecting to %s:%d", host, port);If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
format
- a format string compatible with String.format()args
- arguments for the format stringpublic void error(Throwable exception, String message)
exception
- an exception associated with the error being loggedmessage
- a literal message to logpublic void error(String message)
message
- a literal message to logpublic void error(@Nullable Throwable exception, String format, Object... args)
logger.error(e, "something really bad happened when connecting to %s:%d", host, port);If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
exception
- an exception associated with the error being loggedformat
- a format string compatible with String.format()args
- arguments for the format stringpublic void error(Throwable exception)
exception.getMessage()
will be used as the
log message. logger.error(e);
exception
- an exception associated with the error being loggedpublic void error(String format, Object... args)
logger.error("something really bad happened when connecting to %s:%d", host, port);If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
format
- a format string compatible with String.format()args
- arguments for the format stringpublic boolean isVerboseEnabled()
public boolean isDebugEnabled()
public Level getLevel()
public void setLevel(Level newLevel)
public boolean isLoggable(Level level)
public void addHandler(Handler handler)
public Handler[] getHandlers()