spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Support bridging logs to OpenTelemetry API

Open ThomasVitale opened this issue 1 month ago • 4 comments

Spring Boot offers nice abstractions to configure logs via a unified model. Furthermore, it offers great integrations and customisations for Logback and Log4J2.

The recent addition of structured logging brought many benefits. I wonder if the work that was done for that feature could lay the foundation for implementing a new feature supporting bridging the logs produced by SLF4J/Logback/Log4J2 via the OpenTelemetry API, considering that Spring Boot 4 comes with auto-configuration for OpenTelemetry Logging API and OpenTelemetry Logger Exporter API for OTLP (but no logs are actually exported).

Related/previous work:

As always, I'm happy to help any way I can, if this is something interesting for the project.

ThomasVitale avatar Nov 08 '25 14:11 ThomasVitale

If you add one of the OTel appenders as a dependency and configure it in your logback/log4j xml does it work? If I remember correctly, this should be the intended setup and Boot does not provide more auto-configuration since those appenders are still in -alpha.

jonatan-ivanov avatar Nov 11 '25 00:11 jonatan-ivanov

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.

spring-projects-issues avatar Nov 18 '25 07:11 spring-projects-issues

@jonatan-ivanov thanks for your reply! Yes, it works if I add the bridge libraries from the OpenTelemetry Java Instrumentation project, and they are both still in alpha. What I was thinking with this issue was a solution native to Spring Boot, possibly building on top of the work done for the structured logging feature, so not to have dependencies on the OpenTelemetry Java Instrumentation project in favour of a more stable solution.

ThomasVitale avatar Nov 18 '25 07:11 ThomasVitale

I think another alternative to that is Logback and Log4J2 supporting OTLP "natively" (having an OTLP appender in their "core" module or in an otlp module). I've been thinking of opening issues for a while (basically since OTLP logs are stable) but I think this would have better chances if someone from the community would open it. What do you think?

jonatan-ivanov avatar Nov 18 '25 20:11 jonatan-ivanov