Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture Logback KeyValuePairs #8059

Closed
jack-berg opened this issue Mar 15, 2023 · 0 comments · Fixed by #8074
Closed

Capture Logback KeyValuePairs #8059

jack-berg opened this issue Mar 15, 2023 · 0 comments · Fixed by #8074
Labels
enhancement New feature or request

Comments

@jack-berg
Copy link
Member

If I use the SLF4J 2.0.0 fluent API to do structured logging as follows:

            slf4jLogger
                .atInfo()
                .setMessage("A slf4j structured message")
                .addKeyValue("key", "value")
                .log()

I expect the key value pairs I add via addKeyValue(...) to be included in OpenTelemetry LogRecords when I use the logback appender.

Key value pairs are currently dropped. This appears to happen because the logback appender supports logback v1+, and a new API ILoggingEvent#getKeyValuePairs was added in logback v1.3.

We should add support to the logback appender to capture keyvalue pairs.

Note, this isn't a problem if using log4j2 as an implementation of slf4j2 via log4j-slf4j2-impl. Slf4j2 key value pairs are captured in log4j2 context data, which is accessed via LogEvent#getContextData(). There's already a property in the log4j2 appender config to capture context data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant