Repository navigation
logging: add structuredMessageOf, for a serializable value's fields - #124
Merged
Merged
Conversation
rocketraman
force-pushed
the
rg/structured-message-serialization
branch
from
November 25, 2026 18:32
dcc7ace to
18a28f1
Compare
|
boot-logging-log4j2-serialization's structuredMessageOf encodes a @serializable value with kotlinx.serialization and makes a StructuredMessage with each property as a field. A nested object's properties are named with a dot, numbers and booleans keep their types, lists stay lists, and nulls are left out. An optional prefix starts each field's name. It is its own module, so that boot-logging-log4j2 doesn't bring kotlinx-serialization-json to every application.
rocketraman
force-pushed
the
rg/structured-message-serialization
branch
from
November 25, 2026 19:06
18a28f1 to
09473bd
Compare
rocketraman
marked this pull request as ready for review
November 25, 2026 19:07
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #123, which adds
StructuredMessage.A new module,
boot-logging-log4j2-serialization, addsstructuredMessageOf. It makes aStructuredMessagefrom a@Serializablevalue, with each of the value's properties as a field:JsonElementwith kotlinx.serialization'sJson, or with ajsonthe caller passes, so@SerialNameand theJsonconfiguration apply.refund.customer.id.JSONwrites as an array), and anullis left out.prefixis optional. A value that isn't encoded as an object, such as a number, is a single field named by the prefix, which it then requires.SerializationStrategy.It is a separate module so that
boot-logging-log4j2doesn't bringkotlinx-serialization-jsonto every application.Tests and docs
StructuredMessageOfTestchecks the fields, their names and types, the prefix, a non-object value, and the output through theJSONlayout.modules.ymlas an optional group, and to the CHANGELOG.