Interface Logger
-
- All Known Subinterfaces:
FormatterLogger
@ProviderType public interface Logger
Provides methods for bundles to write messages to the log using SLF4J-style format strings.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/orServiceReference
to the generatedLogEntry
by passing them to the logging methods as additional arguments. If the last argument is aThrowable
or aServiceReference
, it is added to the generatedLogEntry
and then, if the next to last argument is aServiceReference
orThrowable
and not the same type as the last argument, it is also added to the generatedLogEntry
. 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);
- Since:
- 1.4
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ROOT_LOGGER_NAME
Root Logger Name.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
audit(java.lang.String message)
Log a message at theLogLevel.AUDIT
level.void
audit(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.AUDIT
level.void
audit(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.AUDIT
level.void
audit(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.AUDIT
level.void
debug(java.lang.String message)
Log a message at theLogLevel.DEBUG
level.void
debug(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.DEBUG
level.void
debug(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.DEBUG
level.void
debug(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.DEBUG
level.<E extends java.lang.Exception>
voiddebug(LoggerConsumer<E> consumer)
Perform the specified operation if logging enabled for theLogLevel.DEBUG
level.void
error(java.lang.String message)
Log a message at theLogLevel.ERROR
level.void
error(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.ERROR
level.void
error(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.ERROR
level.void
error(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.ERROR
level.<E extends java.lang.Exception>
voiderror(LoggerConsumer<E> consumer)
Perform the specified operation if logging enabled for theLogLevel.ERROR
level.java.lang.String
getName()
Return the name of this Logger.void
info(java.lang.String message)
Log a message at theLogLevel.INFO
level.void
info(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.INFO
level.void
info(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.INFO
level.void
info(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.INFO
level.<E extends java.lang.Exception>
voidinfo(LoggerConsumer<E> consumer)
Perform the specified operation if logging enabled for theLogLevel.INFO
level.boolean
isDebugEnabled()
Is logging enabled for theLogLevel.DEBUG
level?boolean
isErrorEnabled()
Is logging enabled for theLogLevel.ERROR
level?boolean
isInfoEnabled()
Is logging enabled for theLogLevel.INFO
level?boolean
isTraceEnabled()
Is logging enabled for theLogLevel.TRACE
level?boolean
isWarnEnabled()
Is logging enabled for theLogLevel.WARN
level?void
trace(java.lang.String message)
Log a message at theLogLevel.TRACE
level.void
trace(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.TRACE
level.void
trace(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.TRACE
level.void
trace(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.TRACE
level.<E extends java.lang.Exception>
voidtrace(LoggerConsumer<E> consumer)
Perform the specified operation if logging enabled for theLogLevel.TRACE
level.void
warn(java.lang.String message)
Log a message at theLogLevel.WARN
level.void
warn(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.WARN
level.void
warn(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.WARN
level.void
warn(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.WARN
level.<E extends java.lang.Exception>
voidwarn(LoggerConsumer<E> consumer)
Perform the specified operation if logging enabled for theLogLevel.WARN
level.
-
-
-
Field Detail
-
ROOT_LOGGER_NAME
static final java.lang.String ROOT_LOGGER_NAME
Root Logger Name.- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
java.lang.String getName()
Return the name of this Logger.- Returns:
- The name of this Logger.
-
isTraceEnabled
boolean isTraceEnabled()
Is logging enabled for theLogLevel.TRACE
level?- Returns:
true
if logging is enabled for theLogLevel.TRACE
level.
-
trace
void trace(java.lang.String message)
Log a message at theLogLevel.TRACE
level.- Parameters:
message
- The message to log.
-
trace
void trace(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.TRACE
level.- Parameters:
format
- The format of the message to log.arg
- The argument to format into the message.
-
trace
void trace(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.TRACE
level.- Parameters:
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.
-
trace
void trace(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.TRACE
level.- Parameters:
format
- The format of the message to log.arguments
- The arguments to format into the message.
-
trace
<E extends java.lang.Exception> void trace(LoggerConsumer<E> consumer) throws E extends java.lang.Exception
Perform the specified operation if logging enabled for theLogLevel.TRACE
level.- Parameters:
consumer
- The operation to perform on this Logger.- Throws:
E
- An exception thrown by the operation.E extends java.lang.Exception
-
isDebugEnabled
boolean isDebugEnabled()
Is logging enabled for theLogLevel.DEBUG
level?- Returns:
true
if logging is enabled for thetrace
level.
-
debug
void debug(java.lang.String message)
Log a message at theLogLevel.DEBUG
level.- Parameters:
message
- The message to log.
-
debug
void debug(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.DEBUG
level.- Parameters:
format
- The format of the message to log.arg
- The argument to format into the message.
-
debug
void debug(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.DEBUG
level.- Parameters:
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.
-
debug
void debug(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.DEBUG
level.- Parameters:
format
- The format of the message to log.arguments
- The arguments to format into the message.
-
debug
<E extends java.lang.Exception> void debug(LoggerConsumer<E> consumer) throws E extends java.lang.Exception
Perform the specified operation if logging enabled for theLogLevel.DEBUG
level.- Parameters:
consumer
- The operation to perform on this Logger.- Throws:
E
- An exception thrown by the operation.E extends java.lang.Exception
-
isInfoEnabled
boolean isInfoEnabled()
Is logging enabled for theLogLevel.INFO
level?- Returns:
true
if logging is enabled for thetrace
level.
-
info
void info(java.lang.String message)
Log a message at theLogLevel.INFO
level.- Parameters:
message
- The message to log.
-
info
void info(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.INFO
level.- Parameters:
format
- The format of the message to log.arg
- The argument to format into the message.
-
info
void info(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.INFO
level.- Parameters:
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.
-
info
void info(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.INFO
level.- Parameters:
format
- The format of the message to log.arguments
- The arguments to format into the message.
-
info
<E extends java.lang.Exception> void info(LoggerConsumer<E> consumer) throws E extends java.lang.Exception
Perform the specified operation if logging enabled for theLogLevel.INFO
level.- Parameters:
consumer
- The operation to perform on this Logger.- Throws:
E
- An exception thrown by the operation.E extends java.lang.Exception
-
isWarnEnabled
boolean isWarnEnabled()
Is logging enabled for theLogLevel.WARN
level?- Returns:
true
if logging is enabled for thetrace
level.
-
warn
void warn(java.lang.String message)
Log a message at theLogLevel.WARN
level.- Parameters:
message
- The message to log.
-
warn
void warn(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.WARN
level.- Parameters:
format
- The format of the message to log.arg
- The argument to format into the message.
-
warn
void warn(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.WARN
level.- Parameters:
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.
-
warn
void warn(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.WARN
level.- Parameters:
format
- The format of the message to log.arguments
- The arguments to format into the message.
-
warn
<E extends java.lang.Exception> void warn(LoggerConsumer<E> consumer) throws E extends java.lang.Exception
Perform the specified operation if logging enabled for theLogLevel.WARN
level.- Parameters:
consumer
- The operation to perform on this Logger.- Throws:
E
- An exception thrown by the operation.E extends java.lang.Exception
-
isErrorEnabled
boolean isErrorEnabled()
Is logging enabled for theLogLevel.ERROR
level?- Returns:
true
if logging is enabled for thetrace
level.
-
error
void error(java.lang.String message)
Log a message at theLogLevel.ERROR
level.- Parameters:
message
- The message to log.
-
error
void error(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.ERROR
level.- Parameters:
format
- The format of the message to log.arg
- The argument to format into the message.
-
error
void error(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.ERROR
level.- Parameters:
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.
-
error
void error(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.ERROR
level.- Parameters:
format
- The format of the message to log.arguments
- The arguments to format into the message.
-
error
<E extends java.lang.Exception> void error(LoggerConsumer<E> consumer) throws E extends java.lang.Exception
Perform the specified operation if logging enabled for theLogLevel.ERROR
level.- Parameters:
consumer
- The operation to perform on this Logger.- Throws:
E
- An exception thrown by the operation.E extends java.lang.Exception
-
audit
void audit(java.lang.String message)
Log a message at theLogLevel.AUDIT
level.- Parameters:
message
- The message to log.
-
audit
void audit(java.lang.String format, java.lang.Object arg)
Log a formatted message at theLogLevel.AUDIT
level.- Parameters:
format
- The format of the message to log.arg
- The argument to format into the message.
-
audit
void audit(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
Log a formatted message at theLogLevel.AUDIT
level.- Parameters:
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.
-
audit
void audit(java.lang.String format, java.lang.Object... arguments)
Log a formatted message at theLogLevel.AUDIT
level.- Parameters:
format
- The format of the message to log.arguments
- The arguments to format into the message.
-
-