with
Associates a metadata key constant with a runtime value for this log statement in a structured way that is accessible to logger backends.
This method is not a replacement for general parameter passing in the log method and should be reserved for keys/values with specific semantics. Examples include:
- Keys that are recognised by specific logger backends (typically to control logging behaviour in some way).
- Key value pairs which are explicitly extracted from logs by tools.
Metadata keys can support repeated values (see canRepeat), and if a repeatable key is used multiple times in the same log statement, the effect is to collect all the given values in order. If a non-repeatable key is passed multiple times, only the last value is retained (though callers should not rely on this behavior and should simply avoid repeating non-repeatable keys).
If value is null, this method is a no-op. This is useful for specifying conditional values (e.g. via logger.atInfo().with(MY_KEY, getValueOrNull()).log(...)).
Parameters
the metadata key (expected to be a static constant)
a value to be associated with the key in this log statement. Null values are allowed, but the effect is always a no-op
See also
Throws
if the given key is null
Sets a boolean metadata key constant to true for this log statement in a structured way that is accessible to logger backends.
This method is not a replacement for general parameter passing in the log method and should be reserved for keys/values with specific semantics. Examples include:
- Keys that are recognised by specific logger backends (typically to control logging behaviour in some way).
- Key value pairs which are explicitly extracted from logs by tools.
This method is just an alias for with(key, true) to improve readability.
Parameters
the boolean metadata key (expected to be a static constant)
See also
Throws
if the given key is null