You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the sentry-spring-boot-starter-jakarta library. However, I have discovered that warning logs during the application startup are not being sent to Sentry. In SentryLogbackAppenderAutoConfiguration, the autoconfiguration for SentryLogbackInitializer is found, and this configuration seems to be too late.
Spring publishes events in the order described in Spring Application Events and Listeners. When configuring SentryAppender directly via logback-spring.xml without using the sentry-spring-boot-starter-jakarta library, the SentryAppender is initialized at the time of the ApplicationEnvironmentPreparedEvent publication. This is an earlier initialization point. Please refer to LoggingApplicationListener.java#L218.
Solution Brainstorm
Instead of using SentryLogbackAppenderAutoConfiguration, how about registering the listener quickly by configuring it in spring.factories like:
Currently, SentryLogbackInitializer supports events of type ContextRefreshedEvent, but even with early listener registration, a lot of tasks may already have been performed by the time ContextRefreshedEvent is published. Can we initialize it at the time of ApplicationEnvironmentPreparedEvent publication?
The text was updated successfully, but these errors were encountered:
Thanks for opening this issue @ghoonch4! We'll look into this but I'm guessing specifying it in spring.factories would cause problems for users not having the logback dependency. We load some of our config conditionally (depending on classes available), which is what SentryLogbackAppenderAutoConfiguration does via some @ConditionalOn... annotations. Our current suggestion is to configure the logback XML config file if you want startup logs to be captured.
Problem Statement
I am trying to use the
sentry-spring-boot-starter-jakarta
library. However, I have discovered that warning logs during the application startup are not being sent to Sentry. InSentryLogbackAppenderAutoConfiguration
, the autoconfiguration forSentryLogbackInitializer
is found, and this configuration seems to be too late.Spring publishes events in the order described in Spring Application Events and Listeners. When configuring
SentryAppender
directly vialogback-spring.xml
without using thesentry-spring-boot-starter-jakarta
library, theSentryAppender
is initialized at the time of theApplicationEnvironmentPreparedEvent
publication. This is an earlier initialization point. Please refer to LoggingApplicationListener.java#L218.Solution Brainstorm
SentryLogbackAppenderAutoConfiguration
, how about registering the listener quickly by configuring it inspring.factories
like:SentryLogbackInitializer
supports events of typeContextRefreshedEvent
, but even with early listener registration, a lot of tasks may already have been performed by the timeContextRefreshedEvent
is published. Can we initialize it at the time ofApplicationEnvironmentPreparedEvent
publication?The text was updated successfully, but these errors were encountered: