public final class MDCUtils extends Object
| Constructor and Description |
|---|
MDCUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Throwable |
decorateWithMdcContext(Throwable exception)
Checks whether the MDC context has been captured somewhere on the causal chain already, and if not, wraps the
exception in an
MDCCapturingException or MDCCapturingRuntimeException. |
static <T> T |
doWithMdcContext(Callable<T> task,
Object... context)
Execute a task returning a result with a set of key-value pairs on the
MDC log context, wrapping any
exception thrown from the task in a MDCCapturingException to capture the full current MDC context if
necessary. |
static Map<String,String> |
gatherMdcContext(Throwable exception)
Finds all MDC context information in the causal chain and combines them
into one map.
|
public static Map<String,String> gatherMdcContext(Throwable exception)
exception - The exception for which to gather the MDC context
information.Map, but never null.public static <T> T doWithMdcContext(Callable<T> task, Object... context)
MDC log context, wrapping any
exception thrown from the task in a MDCCapturingException to capture the full current MDC context if
necessary.task - The task to execute.context - An interleaved list of keys and values. Must have an even length. The keys must be
Strings. The values may be any type and will be converted to a string by invoking
toString(). They may also be null, in which case the string "null" will be
placed on the context.public static Throwable decorateWithMdcContext(Throwable exception)
MDCCapturingException or MDCCapturingRuntimeException.exception - The exception to check for the presence of a captured MDC context.Copyright © 2011–2025 pepsoft.org. All rights reserved.