Reputation: 39
Is it possible to disable LoggingFailureAnalysisReporter
execution during spring boot failure?
I made a custom FailureAnalysisReporter
and I don't want to report twice.
Upvotes: 1
Views: 10423
Reputation: 39
I just found a way to archive what i want, simply adding: <logger name="org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter" level="OFF" />
to my logback
configuration will disable any logging from this class, which is essencialy the only thing LoggingFailureAnalysisReporter
do.
Upvotes: 2
Reputation: 1157
You can achieve that by overriding the spring.factories
configuration of spring-boot
:
Replacing :
# FailureAnalysisReporters
org.springframework.boot.diagnostics.FailureAnalysisReporter=\
org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter
With:
# FailureAnalysisReporters
org.springframework.boot.diagnostics.FailureAnalysisReporter=\
your.own.implementation.of.FailureAnalysisReporter
UPDATE:
Overriding spring.factories
means creating a spring.factories
file under your-project-root/src/main/resources/META-INF
. Hence spring-boot
will load the properties overridden and keep the others unchanged.
Spring Boot checks for the presence of a META-INF/spring.factories file within your published jar. The file should list your configuration classes under the EnableAutoConfiguration key.
See documentation : https://docs.spring.io/autorepo/docs/spring-boot/2.0.0.M3/reference/html/boot-features-developing-auto-configuration.html
Upvotes: -1