Skip to content

Support slf4j/logback fluent logging and key-value pairs in logback logging integration #5445

@MiguelGL-DN

Description

@MiguelGL-DN

Problem Statement

We are using SLF4J fluent logging API -- https://www.slf4j.org/manual.html#fluent in a Spring Boot application using logback as implementation.

We have enabled Sentry logback integration

    ...
    <appender name="SENTRY" class="io.sentry.logback.SentryAppender">
        <options>
            <debug>true</debug>
            <dsn>CHANGE-IT</dsn>
        </options>
        <minimumBreadcrumbLevel>INFO</minimumBreadcrumbLevel>
        <minimumEventLevel>ERROR</minimumEventLevel>
    </appender>
    ...

Dependencies:

...
[INFO] +- io.sentry:sentry-spring-boot-starter-jakarta:jar:8.11.1:compile
[INFO] |  \- io.sentry:sentry-spring-boot-jakarta:jar:8.11.1:compile
[INFO] |     +- io.sentry:sentry-spring-jakarta:jar:8.11.1:compile
[INFO] |     \- io.sentry:sentry-reactor:jar:8.11.1:compile
[INFO] +- io.sentry:sentry-logback:jar:8.11.1:compile
[INFO] |  \- io.sentry:sentry:jar:8.11.1:compile
...
[INFO] +- org.springframework.boot:spring-boot-starter-logging:jar:3.4.4:compile
[INFO] |  +- ch.qos.logback:logback-classic:jar:1.5.18:compile
[INFO] |  \- org.apache.logging.log4j:log4j-to-slf4j:jar:2.24.3:compile
[INFO] |     \- org.apache.logging.log4j:log4j-api:jar:2.24.3:compile
...
[INFO] +- org.slf4j:jul-to-slf4j:jar:2.0.17:compile
[INFO] +- ch.qos.logback:logback-core:jar:1.5.18:compile
...
[INFO] +- io.sentry:sentry-logback:jar:8.11.1:compile
[INFO] |  \- io.sentry:sentry:jar:8.11.1:compile
...

Our log messages look like this:

log.atError()
    .addKeyValue("key1", valueInstance1)
    .addKeyValue("key2", valueInstance2)
    .setMessage("Error doing blah blah blah")
    .setCause(ex)
    .log()

Our problem is that in Sentry dashboard we are not seeing the key-value'd information, and instead we are only seeing the "Error doing ..." message.

In our log file we are indeed seeing these values via ... [%kvp] ... in the file log pattern set via our logback-spring.xml.

Please add support for this usage pattern in the Java SDK. If this is already supported and I missed it from the documentation, please point me towards it, thanks!

Solution Brainstorm

No response

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions