I have a spring boot application that uses logback-spring.xml
to configure console or file appenders and logstash appender added programmatically because it requires dynamic properties from my application.
It works well on app startup, but when I modify log level in logback-spring.xml
the LoggerContext
is reset and only the static configuration from logback-spring.xml
is reloaded and so the logstash appender is no longer used.
Behavior is the same with plain logback.xml
So far, the only workaround I found is to add a LoggerContextListener
that adds logstash appender on reset event. It works but I wonder whether this is the best way.
I also thought of adding a listener to ReconfigureOnChangeTask but the addListener() method is package protected.
I am using logback-classic 1.1.7 and spring-boot 1.4.0.
Thanks,