Package org.slf4j.spi
Interface LoggingEventBuilder
- All Known Implementing Classes:
DefaultLoggingEventBuilder
,NOPLoggingEventBuilder
public interface LoggingEventBuilder
This is the main interface in slf4j's fluent API for creating
logging events
.- Since:
- 2.0.0
- Author:
- Ceki Gülcü
-
Method Summary
Modifier and TypeMethodDescriptionAdd an argument to the event being built.addArgument
(Supplier<?> objectSupplier) Add an argument supplier to the event being built.addKeyValue
(String key, Object value) Add akey value pair
to the event being built.addKeyValue
(String key, Supplier<Object> valueSupplier) Add akey value pair
to the event being built.Amarker
to the event being built.void
log()
After the logging event is built, performs actual logging.void
Equivalent to callingsetMessage(String)
followed bylog()
;void
void
Equivalent to callingsetMessage(String)
followed by zero or more calls toaddArgument(Object)
(depending on the size of args array) and thenlog()
void
Equivalent to callingsetMessage(String)
followed by two calls toaddArgument(Object)
and thenlog()
void
Equivalent to callingsetMessage(Supplier)
followed bylog()
Set the cause for the logging event being built.setMessage
(String message) Sets the message of the logging event.setMessage
(Supplier<String> messageSupplier) Sets the message of the event via a message supplier.
-
Method Details
-
setCause
Set the cause for the logging event being built.- Parameters:
cause
- a throwable- Returns:
- a LoggingEventBuilder, usually this.
-
addMarker
Amarker
to the event being built.- Parameters:
marker
- a Marker instance to add.- Returns:
- a LoggingEventBuilder, usually this.
-
addArgument
Add an argument to the event being built.- Parameters:
p
- an Object to add.- Returns:
- a LoggingEventBuilder, usually this.
-
addArgument
Add an argument supplier to the event being built.- Parameters:
objectSupplier
- an Object supplier to add.- Returns:
- a LoggingEventBuilder, usually this.
-
addKeyValue
Add akey value pair
to the event being built.- Parameters:
key
- the key of the key value pair.value
- the value of the key value pair.- Returns:
- a LoggingEventBuilder, usually this.
-
addKeyValue
Add akey value pair
to the event being built.- Parameters:
key
- the key of the key value pair.valueSupplier
- a supplier of a value for the key value pair.- Returns:
- a LoggingEventBuilder, usually this.
-
setMessage
Sets the message of the logging event.- Since:
- 2.0.0-beta0
-
setMessage
Sets the message of the event via a message supplier.- Parameters:
messageSupplier
- supplies a String to be used as the message for the event- Since:
- 2.0.0-beta0
-
log
void log()After the logging event is built, performs actual logging. This method must be called for logging to occur. If the call tolog()
is omitted, aLoggingEvent
will be built but no logging will occur.- Since:
- 2.0.0-beta0
-
log
Equivalent to callingsetMessage(String)
followed bylog()
;- Parameters:
message
- the message to log
-
log
- Parameters:
message
- the message to logarg
- an argument to be used with the message to log
-
log
Equivalent to callingsetMessage(String)
followed by two calls toaddArgument(Object)
and thenlog()
- Parameters:
message
- the message to logarg0
- first argument to be used with the message to logarg1
- second argument to be used with the message to log
-
log
Equivalent to callingsetMessage(String)
followed by zero or more calls toaddArgument(Object)
(depending on the size of args array) and thenlog()
- Parameters:
message
- the message to logargs
- a list (actually an array) of arguments to be used with the message to log
-
log
Equivalent to callingsetMessage(Supplier)
followed bylog()
- Parameters:
messageSupplier
- a Supplier returning a message of type String
-