How do I programmatically tell Logback 1.4.x to Reload Configuration?
I found an answer to reload logback 1.2.x configuration but it doesn't work with logback 1.4.x (nor 1.3.x) as it gives a compilation error:
The method findURLOfDefaultConfigurationFile(boolean) is undefined for the type ContextInitializer
In Logback 1.4.x, the method
findURLOfDefaultConfigurationFile(boolean)is indeed not available. Instead, Logback 1.4.x introduced a new way to programmatically reload its configuration using the LoggerContext class. To programmatically trigger a configuration reload, you can use the following approach:In this code:
Finally, I log a message to indicate that the configuration was reloaded.