Skip to content

Implement custom Logback JSON encoder#30

Merged
vlaurin merged 1 commit intomainfrom
custom-json-encoder
Mar 18, 2025
Merged

Implement custom Logback JSON encoder#30
vlaurin merged 1 commit intomainfrom
custom-json-encoder

Conversation

@vlaurin
Copy link
Copy Markdown
Contributor

@vlaurin vlaurin commented Mar 17, 2025

Native Logback JSON encoder does not provide a satisfactory encoding, this changes build on the code of the native encoder to offer a more suitable output format:

  • Serialise formattedMessage as message with raw message and arguments dropped
  • Serialise key/value pairs as object kvp, not list: keys should not be duplicated or they will be overridden
  • Serialise stacktrace as exception instead of throwable
  • Empty lists/maps are implicitly hidden instead of being serialised as null

Native Logback JSON encoder does not provide a satisfactory encoding, this changes build on the code of the native encoder to offer a more suitable output format:
- Serialise `formattedMessage` as `message` with raw message and arguments dropped
- Serialise key/value pairs as object `kvp`, not list: keys should not be duplicated or they will be overridden
- Serialise stacktrace as `exception` instead of `throwable`
- Empty lists/maps are implicitly hidden instead of being serialised as `null`
@vlaurin vlaurin merged commit 053881b into main Mar 18, 2025
2 checks passed
@vlaurin vlaurin deleted the custom-json-encoder branch March 18, 2025 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants