At my company we currently maintain a custom starter that support logging to console, file, a kafka topic and an http endpoint. However, the current setup heavily relies on custom configuration via logback-spring.xml
and also uses if conditions which requires janino and thus is not compatible with GraalVM native image. With the latest spring boot release, we successfully switched our console and file logging over to the new structured logging feature but still have to maintain our "old" starter for logging to kafka and an http endpoint. Our goal is to have full compatability with GraalVM in the future, so we're actively looking for solutions here.
Would it be possible to allow users of spring to define additional appenders for structured logging in DefaultLogbackConfiguration#apply so that we can basically re-use the whole formatting logic or would you recommend a different approach?
Probably related to: * https://github.com/spring-projects/spring-boot/issues/25847 * https://github.com/spring-projects/spring-boot/issues/33758
Comment From: philwebb
Currently both LogbackConfigurator
and DefaultLogbackConfiguration
are package private and I don't think we'd really want to make them public if we can at all help it.
I don't have a lot of good ideas to suggest, but perhaps we could add a hook point in org.springframework.boot.logging.logback.LogbackLoggingSystem.loadDefaults(LoggingInitializationContext, LogFile)
that could delegate to something loaded from spring.factories
. You could at least then copy/paste our initialization code to do what you need. I'm not sure if such an approach would help or hinder future efforts to fix #25847.
Flagging to see what the rest of the team think.
Comment From: philwebb
We discussed this today and I'm afraid we don't have a good answer currently. We think that this issue is a duplicate of #25847, but we don't have an ETA for a fix for that one. You're best approach for now might be to disable Spring Boot's logging support entirely and instead develop your own programmatic configuration.