@ProviderType
public interface Logger
Messages can be formatted by the Logger once the Logger determines the log
level is enabled. Use a left curly bracket ('{'
\u007B)
followed by a right curly bracket ('}'
\u007D) as a place
holder for an argument: "{}"
. If you need to use the literal
"{}"
in the formatted message, precede the place holder with a
reverse solidus ('\'
\u005C): "\{}"
. If you need to
place a backslash before the place holder, precede the reverse solidus with a
reverse solidus: "\\{}"
.
You can also add a Throwable
and/or ServiceReference
to the
generated LogEntry
by passing them to the logging methods as
additional arguments. If the last argument is a Throwable
or a
ServiceReference
, it is added to the generated LogEntry
and
then, if the next to last argument is a ServiceReference
or
Throwable
and not the same type as the last argument, it is also
added to the generated LogEntry
. These arguments will not be used as
message arguments. For example:
logger.info("Found service {}.", serviceReference, serviceReference); logger.warn("Something named {} happened.", name, serviceReference, throwable); logger.error("Failed.", exception);
Modifier and Type | Field and Description |
---|---|
static String |
ROOT_LOGGER_NAME
Root Logger Name.
|
Modifier and Type | Method and Description |
---|---|
void |
audit(String message)
Log a message at the
LogLevel.AUDIT level. |
void |
audit(String format,
Object... arguments)
Log a formatted message at the
LogLevel.AUDIT level. |
void |
audit(String format,
Object arg)
Log a formatted message at the
LogLevel.AUDIT level. |
void |
audit(String format,
Object arg1,
Object arg2)
Log a formatted message at the
LogLevel.AUDIT level. |
<E extends Exception> |
debug(LoggerConsumer<E> consumer)
Perform the specified operation if logging enabled for the
LogLevel.DEBUG level. |
void |
debug(String message)
Log a message at the
LogLevel.DEBUG level. |
void |
debug(String format,
Object... arguments)
Log a formatted message at the
LogLevel.DEBUG level. |
void |
debug(String format,
Object arg)
Log a formatted message at the
LogLevel.DEBUG level. |
void |
debug(String format,
Object arg1,
Object arg2)
Log a formatted message at the
LogLevel.DEBUG level. |
<E extends Exception> |
error(LoggerConsumer<E> consumer)
Perform the specified operation if logging enabled for the
LogLevel.ERROR level. |
void |
error(String message)
Log a message at the
LogLevel.ERROR level. |
void |
error(String format,
Object... arguments)
Log a formatted message at the
LogLevel.ERROR level. |
void |
error(String format,
Object arg)
Log a formatted message at the
LogLevel.ERROR level. |
void |
error(String format,
Object arg1,
Object arg2)
Log a formatted message at the
LogLevel.ERROR level. |
String |
getName()
Return the name of this Logger.
|
<E extends Exception> |
info(LoggerConsumer<E> consumer)
Perform the specified operation if logging enabled for the
LogLevel.INFO level. |
void |
info(String message)
Log a message at the
LogLevel.INFO level. |
void |
info(String format,
Object... arguments)
Log a formatted message at the
LogLevel.INFO level. |
void |
info(String format,
Object arg)
Log a formatted message at the
LogLevel.INFO level. |
void |
info(String format,
Object arg1,
Object arg2)
Log a formatted message at the
LogLevel.INFO level. |
boolean |
isDebugEnabled()
Is logging enabled for the
LogLevel.DEBUG level? |
boolean |
isErrorEnabled()
Is logging enabled for the
LogLevel.ERROR level? |
boolean |
isInfoEnabled()
Is logging enabled for the
LogLevel.INFO level? |
boolean |
isTraceEnabled()
Is logging enabled for the
LogLevel.TRACE level? |
boolean |
isWarnEnabled()
Is logging enabled for the
LogLevel.WARN level? |
<E extends Exception> |
trace(LoggerConsumer<E> consumer)
Perform the specified operation if logging enabled for the
LogLevel.TRACE level. |
void |
trace(String message)
Log a message at the
LogLevel.TRACE level. |
void |
trace(String format,
Object... arguments)
Log a formatted message at the
LogLevel.TRACE level. |
void |
trace(String format,
Object arg)
Log a formatted message at the
LogLevel.TRACE level. |
void |
trace(String format,
Object arg1,
Object arg2)
Log a formatted message at the
LogLevel.TRACE level. |
<E extends Exception> |
warn(LoggerConsumer<E> consumer)
Perform the specified operation if logging enabled for the
LogLevel.WARN level. |
void |
warn(String message)
Log a message at the
LogLevel.WARN level. |
void |
warn(String format,
Object... arguments)
Log a formatted message at the
LogLevel.WARN level. |
void |
warn(String format,
Object arg)
Log a formatted message at the
LogLevel.WARN level. |
void |
warn(String format,
Object arg1,
Object arg2)
Log a formatted message at the
LogLevel.WARN level. |
static final String ROOT_LOGGER_NAME
String getName()
boolean isTraceEnabled()
LogLevel.TRACE
level?true
if logging is enabled for the LogLevel.TRACE
level.void trace(String message)
LogLevel.TRACE
level.message
- The message to log.void trace(String format, Object arg)
LogLevel.TRACE
level.format
- The format of the message to log.arg
- The argument to format into the message.void trace(String format, Object arg1, Object arg2)
LogLevel.TRACE
level.format
- The format of the message to log.arg1
- The first argument to format into the message.arg2
- The second argument to format into the message.void trace(String format, Object... arguments)
LogLevel.TRACE
level.format
- The format of the message to log.arguments
- The arguments to format into the message.<E extends Exception> void trace(LoggerConsumer<E> consumer) throws E extends Exception
LogLevel.TRACE
level.consumer
- The operation to perform on this Logger.E
- An exception thrown by the operation.E extends Exception
boolean isDebugEnabled()
LogLevel.DEBUG
level?true
if logging is enabled for the trace
level.void debug(String message)
LogLevel.DEBUG
level.message
- The message to log.void debug(String format, Object arg)
LogLevel.DEBUG
level.format
- The format of the message to log.arg
- The argument to format into the message.void debug(String format, Object arg1, Object arg2)
LogLevel.DEBUG
level.format
- The format of the message to log.arg1
- The first argument to format into the message.arg2
- The second argument to format into the message.void debug(String format, Object... arguments)
LogLevel.DEBUG
level.format
- The format of the message to log.arguments
- The arguments to format into the message.<E extends Exception> void debug(LoggerConsumer<E> consumer) throws E extends Exception
LogLevel.DEBUG
level.consumer
- The operation to perform on this Logger.E
- An exception thrown by the operation.E extends Exception
boolean isInfoEnabled()
LogLevel.INFO
level?true
if logging is enabled for the trace
level.void info(String message)
LogLevel.INFO
level.message
- The message to log.void info(String format, Object arg)
LogLevel.INFO
level.format
- The format of the message to log.arg
- The argument to format into the message.void info(String format, Object arg1, Object arg2)
LogLevel.INFO
level.format
- The format of the message to log.arg1
- The first argument to format into the message.arg2
- The second argument to format into the message.void info(String format, Object... arguments)
LogLevel.INFO
level.format
- The format of the message to log.arguments
- The arguments to format into the message.<E extends Exception> void info(LoggerConsumer<E> consumer) throws E extends Exception
LogLevel.INFO
level.consumer
- The operation to perform on this Logger.E
- An exception thrown by the operation.E extends Exception
boolean isWarnEnabled()
LogLevel.WARN
level?true
if logging is enabled for the trace
level.void warn(String message)
LogLevel.WARN
level.message
- The message to log.void warn(String format, Object arg)
LogLevel.WARN
level.format
- The format of the message to log.arg
- The argument to format into the message.void warn(String format, Object arg1, Object arg2)
LogLevel.WARN
level.format
- The format of the message to log.arg1
- The first argument to format into the message.arg2
- The second argument to format into the message.void warn(String format, Object... arguments)
LogLevel.WARN
level.format
- The format of the message to log.arguments
- The arguments to format into the message.<E extends Exception> void warn(LoggerConsumer<E> consumer) throws E extends Exception
LogLevel.WARN
level.consumer
- The operation to perform on this Logger.E
- An exception thrown by the operation.E extends Exception
boolean isErrorEnabled()
LogLevel.ERROR
level?true
if logging is enabled for the trace
level.void error(String message)
LogLevel.ERROR
level.message
- The message to log.void error(String format, Object arg)
LogLevel.ERROR
level.format
- The format of the message to log.arg
- The argument to format into the message.void error(String format, Object arg1, Object arg2)
LogLevel.ERROR
level.format
- The format of the message to log.arg1
- The first argument to format into the message.arg2
- The second argument to format into the message.void error(String format, Object... arguments)
LogLevel.ERROR
level.format
- The format of the message to log.arguments
- The arguments to format into the message.<E extends Exception> void error(LoggerConsumer<E> consumer) throws E extends Exception
LogLevel.ERROR
level.consumer
- The operation to perform on this Logger.E
- An exception thrown by the operation.E extends Exception
void audit(String message)
LogLevel.AUDIT
level.message
- The message to log.void audit(String format, Object arg)
LogLevel.AUDIT
level.format
- The format of the message to log.arg
- The argument to format into the message.void audit(String format, Object arg1, Object arg2)
LogLevel.AUDIT
level.format
- The format of the message to log.arg1
- The first argument to format into the message.arg2
- The second argument to format into the message.void audit(String format, Object... arguments)
LogLevel.AUDIT
level.format
- The format of the message to log.arguments
- The arguments to format into the message.Copyright © 2022 OSGi Alliance. All rights reserved.