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

Support structured logback messages via logstash encoder #5969

Open
trask opened this issue May 3, 2022 · 2 comments
Open

Support structured logback messages via logstash encoder #5969

trask opened this issue May 3, 2022 · 2 comments
Labels
contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome enhancement New feature or request

Comments

@trask
Copy link
Member

trask commented May 3, 2022

This has come up a few times:

Unfortunately, logback has no native structured log message support (other than MDC, which is not ideal, see discussion in first link above).

Logstash Json Encoder seems to be reasonably popular and fills this gap. Unfortunately, the logstash StructuredArgument API is defined around arbitrary Json data, and so maybe(?) the best we can do from translating it to OTel attributes is to take the top-level key/values, where the values may be arbitrarily nested json strings themselves.

@trask trask added the enhancement New feature or request label May 3, 2022
@trask trask self-assigned this Oct 27, 2022
@trask trask removed their assignment Aug 26, 2023
@trask trask added the contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome label Aug 26, 2023
@trask
Copy link
Member Author

trask commented Aug 26, 2023

Unfortunately, logback has no native structured log message support (other than MDC, which is not ideal, see discussion in first link above).

btw, slf4j2 now has structured log message support, so this may be less important now

@oldium
Copy link

oldium commented Oct 22, 2024

Just faced similar issue when migrating from Logstash to OpenTelemetry auto-instrumentation. The code uses LogstashMarker API (actually ObjectAppendingMarker instances, which implements StructuredArgument API) to add some key-value pairs to the log output. And if I read the code correctly, this is transformed into JSON by ArgumentsJsonProvider.

It would be good if OTEL is able to transform StructuredArguments into LogRecord Attributes. For primitive values it could be simple key-value pair, for arrays or object values the value could be JSON serialization into a string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants