spring property not getting populated on refreshing logback file programtically
spring.boot.version: 3.1.12 logback.version:1.4.14 Issue: We are trying to update the logback config at runtime programatically using following code:
public class DynamicLogbackConfigurator {
// Interface to fetch the updated logback xml
private final S3Manager configManager;
public void refresh() throws Exception {
byte[] xml;
val context = (LoggerContext) LoggerFactory.getILoggerFactory();
val configurator = new JoranConfigurator();
try (val logbackContent = configManager.getConfigStoreFile(ManagedFile.LOGBACK_CONFIG)) {
xml = logbackContent.readAllBytes();
} catch (final Exception e) {
log.error("Failed to read logback configuration from config manager.", e);
return;
}
try {
configurator.setContext(context);
context.reset();
configurator.doConfigure(new ByteArrayInputStream(xml));
log.info("Logback configuration has been refreshed from config manager.");
} catch (final Exception e) {
throw e;
}
}
Our logback config has spring property. On doing refresh, its not reading the spring property.
Hello,
Spring Boot 3.1.12 is no longer OSS supported. Please upgrade to an OSS supported version and see if the problem persists. If it does, please create a minimal reproducible sample.
Thanks!
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Checked for spring boot: 3.3.4 logback.version:1.5.8 found same issue. Probably issue is in code we are using JoranConfigurator. Instead we should use SpringBootJoranConfigurator. but SpringBootJoranConfigurator is not a public class
Thanks. Can you please provide a minimal sample for us to reproduce?
log_issue.zip sample application
I think the use of JoranConfigurator is indeed the problem, but I'm not convinced that we should make SpringBootJoranConfigurator public. Programmatically refreshing the logging system isn't something we've considered supporting.
We discussed this today at our team meeting and decided that we'd prefer to keep SpringBootJoranConfigurator package private. Programmatically refreshing the logging system isn't something we can prioritize at the moment.