Skip to content

Sentry Logback with Spring Boot does not pickup configuration from Spring #4521

Closed
@rharrahuzurv

Description

@rharrahuzurv

Integration

sentry

Java Version

24

Version

8.15.0

Steps to Reproduce

Use a Spring Boot 3.4.5 application with Sentry 8.15.0 and enable Sentry logging:

sentry:
  dsn: mydsngoeshere
  send-default-pii: true
  environment: ${ENVIRONMENT_NAME}
  logs:
    enabled: true
  logging:
    minimum-level: info
    minimum-event-level: info
    minimum-breadcrumb-level: debug
    enabled: true

Expected Result

Logs should appear in Sentry Logs.

Actual Result

Logs do not appear in Sentry logs.

As of this line (https://github.com/getsentry/sentry-java/blob/main/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryLogbackInitializer.java#L58), SentryOptions$Logs is correctly detecting from the Spring properties that logs are enabled:
Image

As of this line (https://github.com/getsentry/sentry-java/blob/8.15.0/sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java#L71), SentryOptions$Logs is not using the properties, which is to be expected because these are external configurations:
Image

Once it reaches and invokes the method on this line (https://github.com/getsentry/sentry-java/blob/8.15.0/sentry/src/main/java/io/sentry/Sentry.java#L291) in Sentry.init, it should pick up the external configuration from Spring but does not. It resolves values from environment variables / system properties / classpath but never receives either the DSN or that logs are enabled configured in the Spring properties, resulting in logs never being sent:
Image
Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions