private static MDCAdapter getMDCAdapterGivenByProvider() {
        SLF4JServiceProvider provider = LoggerFactory.getProvider();
        if(provider != null) {
            // If you wish to change the mdc adapter, setting the MDC.MDCAdapter variable might be insufficient.
            // Keep in mind that the provider *might* perform additional internal mdcAdapter assignments that
            // you would also need to replicate/adapt.

            // obtain and attach the MDCAdapter from the provider

            final MDCAdapter anAdapter = provider.getMDCAdapter();
            emitTemporaryMDCAdapterWarningIfNeeded(provider);
            return anAdapter;
        } else {
            Reporter.error("Failed to find provider.");
            Reporter.error("Defaulting to no-operation MDCAdapter implementation.");
            return new NOPMDCAdapter();
        }
    }
An adapter to remove the key when done.
slf4j-api/src/main/java/org/slf4j/MDC.java