DynamicLogLevelProcessor { public void copyDynamicLogLevelToMDC(HttpServletRequest httpRequest) { String logLevelToken = httpRequest.getHeader(dynLogEnvironment.getDynLogHeaderKey()); if (logLevelToken == null) { return; } else { try { DecodedJWT jwt = tokenDecoder.validateAndDecodeToken(logLevelToken); String dynamicLogLevel = jwt.getClaim("level").asString(); if (ALLOWED_DYNAMIC_LOGLEVELS.contains(dynamicLogLevel)) { MDC.put(DynamicLogLevelHelper.MDC_DYNAMIC_LOG_LEVEL_KEY, dynamicLogLevel); } else { throw new DynamicLogLevelException("Dynamic Log-Level [" + dynamicLogLevel + "] provided in header is not valid. Allowed Values are " + ALLOWED_DYNAMIC_LOGLEVELS.toString()); } } catch (DynamicLogLevelException e) { LOGGER.warn("DynamicLogLevelProcessor could not write dynamic log level to MDC", e); } } } DynamicLogLevelProcessor(DynLogEnvironment dynLogEnvironment); void copyDynamicLogLevelToMDC(HttpServletRequest httpRequest); void removeDynamicLogLevelFromMDC();  }
@Test public void testCopyDynamicLogLevelToMDC() throws Exception { processor.copyDynamicLogLevelToMDC(httpRequest); assertEquals("TRACE", MDC.get(DynamicLogLevelHelper.MDC_DYNAMIC_LOG_LEVEL_KEY)); }