Failed to init Sentry during appender initialization: DSN is required
Integration
other
Java Version
21
Version
7.4.0
Steps to Reproduce
io.sentry.jvm.gradle: 4.3.1 spring-boot 3.2.3
if add logback configuration and provide dsn config in application.yaml - fails init appender, but if I pass config via env variable - its works
Demo https://github.com/ramilS/sentry-logback
Expected Result
application.yaml config should work
Actual Result
it is not working
Hello @ramilS, can you try to also add the DSN to your logback.xml?
https://docs.sentry.io/platforms/java/guides/spring-boot/logging-frameworks/ suggestes the following:
You do not need to configure your DSN in the Logback configuration file since Sentry is configured from the Spring Boot integration. However, if errors that may appear during startup should to be sent to Sentry, the DSN must be provided to both the Logback and Spring Boot configurations.
Your repro prints INFO: Initializing SDK with DSN: 'https://[email protected]/1'. I can't find anything in logs that suggest, Sentry wouldn't work.
If you want to have errors during startup reported to Sentry, you can try replacing your appender in logback.xml with:
<appender name="SENTRY" class="io.sentry.logback.SentryAppender">
<options>
<!-- NOTE: Replace the test DSN below with YOUR OWN DSN to see the events from this app in your Sentry project/dashboard -->
<dsn>https://[email protected]/1</dsn>
</options>
</appender>
I did not add any ENV vars for startup. Just enabled debug in application.yaml:
sentry:
dsn: https://[email protected]/1
environment: DEV
debug: true
@adinauer it is working. problem when it provided via application.yaml. application.yaml also works if I remove sentry appender from logback.xml
There's two integrations at play here. Sentry logback and Sentry Spring Boot, both initialize Sentry. The Spring Boot integration also starts the logback appender automatically. You only need to have the appender config and DSN in logback.xml if you want startup errors to be reported to Sentry.
I'm unsure if you need more help or if you got it running the way you need.