java.lang.Object
io.helidon.logging.common.HelidonMdc
Helidon MDC delegates values across all of the supported logging frameworks on the classpath.
Helidon permits adding MDC entries using Supplier<String>
values as well as direct String
values.
Although some logging implementations provide their own context maps (for example ThreadContext
in Log4J and
MDC
in SLF4J), they map MDC keys to String
values, not to arbitrary objects that would accommodate
Supplier<String>
. Therefore, Helidon not only propagates every set
operation to the loaded MDC providers,
but also manages its own map of key/supplier pairs. Helidon resolves each lookup using that map
if possible, delegating a look-up to the loaded MDC providers only if there is no supplier for a key.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
clear()
Remove all of the entries bound to the current thread from the instances ofMdcProvider
.Return the first value found to the specific key.static void
Remove value with the specific key from all of the instances ofMdcProvider
.static void
Propagate value to all of theMdcProvider
registered via SPI.static void
Propagate the value supplier to allMdcProvider
instances registered.static void
setDeferred
(String key, Supplier<String> valueSupplier) Sets a value supplier without immediately getting the value and propagating the value to underlying logging implementations.
-
Method Details
-
set
Propagate value to all of theMdcProvider
registered via SPI.- Parameters:
key
- entry keyvalue
- entry value
-
set
Propagate the value supplier to allMdcProvider
instances registered.- Parameters:
key
- entry keyvalueSupplier
- supplier of the entry value
-
setDeferred
Sets a value supplier without immediately getting the value and propagating the value to underlying logging implementations.Normally, user code should use
set(String, java.util.function.Supplier)
instead.- Parameters:
key
- entry keyvalueSupplier
- supplier of the entry value
-
remove
Remove value with the specific key from all of the instances ofMdcProvider
.- Parameters:
key
- key
-
clear
public static void clear()Remove all of the entries bound to the current thread from the instances ofMdcProvider
. -
get
Return the first value found to the specific key.- Parameters:
key
- key- Returns:
- found value bound to key
-