Study/Java
ApplicationContextRunner에서 Condition Evaluation Report 확인하기
Bluesky_
2024. 12. 29. 05:10
반응형
Spring Boot 기반 autoconfigure 환경을 제공하는 프로젝트 경우 테스트 코드 작성 시 Spring이 제공하는 ApplicationContextRunner
, WebApplicationContextRunner
, ReactiveWebApplicationContextRunner
를 사용하여 작성하게 된다.
예전엔 ApplicationContextRunner
또는 WebApplicationContextRunner
사용 시 debug=true
옵션을 추가하면 boot 관련 로그를 확인할 수 있었다.
버전이 올라가면서 로그를 확인하는 방식이 바뀌었고 기존 코드의 runner 실행 시 로그가 보이지 않게 되었다.
아래처럼 initializer로 ConditionEvaluationReportLoggingListener
를 등록해 주면 기존처럼 로그가 보이게 된다.
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO))
반응형