LogUtil { public static void removeCustomField(final DiagnosticLoggingAdapter loggingAdapter, final String fieldName) { final Map<String, Object> mdc = getMDC(loggingAdapter); mdc.remove(fieldName); loggingAdapter.setMDC(mdc); } private  LogUtil(); static DiagnosticLoggingAdapter obtain(final Actor logSource); static void enhanceLogWithCorrelationId(final DiagnosticLoggingAdapter loggingAdapter,
            final WithDittoHeaders<?> withDittoHeaders, final MdcField... additionalMdcFields); static void enhanceLogWithCorrelationId(final DiagnosticLoggingAdapter loggingAdapter,
            final DittoHeaders dittoHeaders, final MdcField... additionalMdcFields); static void enhanceLogWithCorrelationId(final DiagnosticLoggingAdapter loggingAdapter,
            final Optional<String> correlationId, final MdcField... additionalMdcFields); static void enhanceLogWithCustomField(final MdcField mdcField); static void enhanceLogWithCorrelationId(final DiagnosticLoggingAdapter loggingAdapter,
            final CharSequence correlationId, final MdcField... additionalMdcFields); static void enhanceLogWithCustomField(final DiagnosticLoggingAdapter loggingAdapter,
            final String fieldName,
            @Nullable final CharSequence fieldValue,
            final MdcField... additionalMdcFields); static void enhanceLogWithCorrelationId(final WithDittoHeaders<?> withDittoHeaders); static void enhanceLogWithCorrelationId(final DittoHeaders dittoHeaders); static void enhanceLogWithCorrelationIdOrRandom(final WithDittoHeaders<?> withDittoHeaders); static void enhanceLogWithCorrelationIdOrRandom(final DittoHeaders dittoHeaders); static void enhanceLogWithCorrelationId(final Optional<String> correlationId); static void enhanceLogWithCorrelationId(@Nullable final CharSequence correlationId); static Optional<String> getCorrelationId(); static String getCorrelationId(final Supplier<String> defaultCorrelationIdSupplier); static void removeCorrelationId(); static void removeCustomField(final DiagnosticLoggingAdapter loggingAdapter, final String fieldName); static MdcField newMdcField(final String name, @Nullable final String value); static final String X_CORRELATION_ID; }
@Test public void removeCustomField() { final Map<String, Object> expectedMap = new HashMap<>(DEFAULT_MDC); expectedMap.remove(KNOWN_KEY_1); LogUtil.removeCustomField(log, KNOWN_KEY_1); Mockito.verify(log).setMDC(expectedMap); }