diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index c4d09e903..5240406e0 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,5 +1,6 @@ - + + file = (OutputStreamAppender)root.getAppender("FILE"); + + @SuppressWarnings("unchecked") + byte[] encoded = ((Encoder)file.getEncoder()) + .encode(new LoggingEvent(getClass().getName(), root, Level.ERROR, "test", null, null)); + + assertThat(new String(encoded, UTF_8)).contains("test").doesNotContain("slack-webhook-secret-marker"); + assertThat(context.getProperty("SLACK_WEBHOOK_URI")).isNull(); + SlackAppender slack = (SlackAppender)((AsyncAppender)root.getAppender("ASYNC_SLACK")).getAppender("SLACK"); + assertThat(slack.getWebhookUri()).isEqualTo(WEBHOOK); + } finally { + // 다른 테스트가 같은 JVM에서 쓰는 test 프로필 로그 설정으로 되돌린다. + initialize(loggingSystem, profileEnvironment("test")); + } + } + + private MockEnvironment profileEnvironment(String profile) { + MockEnvironment environment = new MockEnvironment(); + environment.setActiveProfiles(profile); + return environment; + } + + private void initialize(LoggingSystem loggingSystem, MockEnvironment environment) { + loggingSystem.cleanUp(); + loggingSystem.beforeInitialize(); + loggingSystem.initialize(new LoggingInitializationContext(environment), null, null); + } +}