Skip to content

Instantly share code, notes, and snippets.

@chemicL
chemicL / TestMdc.java
Last active March 25, 2024 16:16
Automatic context propagation with MDC using Project Reactor
@Test
void testMDC() {
Logger log = LoggerFactory.getLogger("test");
Hooks.enableAutomaticContextPropagation();
// To deal with the entire MDC (if we ensured no third-party code modifies it):
// ContextRegistry.getInstance().registerThreadLocalAccessor(new MdcAccessor());
// To deal with an individual key in the MDC: