@Override
    public void execute(Map<String, List<String>> parameters, PrintWriter output) throws Exception {
        final List<String> loggerNames = getLoggerNames(parameters);
        final Level loggerLevel = getLoggerLevel(parameters);
        final Duration duration = getDuration(parameters);

        for (String loggerName : loggerNames) {
            Logger logger = ((LoggerContext) loggerContext).getLogger(loggerName);

            String message = String.format("Configured logging level for %s to %s", loggerName, loggerLevel);

            if (loggerLevel != null && duration != null) {
                final long millis = duration.toMillis();
                getTimer().schedule(new TimerTask() {
                    @Override
                    public void run() {
                        logger.setLevel(null);
                    }
                }, millis);

                message += String.format(" for %s milliseconds", millis);
            }

            logger.setLevel(loggerLevel);
            output.println(message);
            output.flush();
        }
    }
@Test
    void configuresSpecificLevelForALoggerForADuration() throws Exception {

        // given
        Level oneEffectiveBefore = logger1.getEffectiveLevel();
        Map<String, List<String>> parameters = Map.of(
            "logger", List.of("logger.one"),
            "level", List.of("debug"),
            "duration", List.of(Duration.ofMillis(2_000).toString()));

        Timer timer = mock(Timer.class);
        ArgumentCaptor<TimerTask> timerAction = ArgumentCaptor.forClass(TimerTask.class);
        ArgumentCaptor<Long> timerDuration = ArgumentCaptor.forClass(Long.class);

        // when
        new LogConfigurationTask(loggerContext, () -> timer).execute(parameters, output);

        // then
        assertThat(logger1.getLevel()).isEqualTo(Level.DEBUG);
        assertThat(stringWriter).hasToString(String.format("Configured logging level for logger.one to DEBUG for 2000 milliseconds%n"));
        verify(timer).schedule(timerAction.capture(), timerDuration.capture());
        assertThat(timerDuration.getValue()).isEqualTo(2_000);

        // after
        timerAction.getValue().run();
        assertThat(logger1.getEffectiveLevel()).isEqualTo(oneEffectiveBefore);
    }