Skip to content

Open up the JsonEncoder for subclassing? #979

@Yaytay

Description

@Yaytay

I cannot find any mechanism that would allow us to output additional JSON when using the JsonEncoder.
By which I mean that I want to be able to extend the JSON model being output.
This is useful when the log output is going to a store that can filter by the JSON content.

The most appropriate place to do this seems to be the KVP list, which only outputs strings.

Ideally I'd like appendKeyValuePairs to have some way to say "is this already a JSON object, and if so output it as JSON".
This doesn't seem very easy for you to add because logback doesn't depend upon any JSON library (also, not sure it would be very efficient for me to have to convert to ObjectNode just for you to convert that to string).

Alternatively I could subclass JsonEncoder, but it does not lend itself to that because too much of it is private (or package-private).
Could the JsonEncoder be made more easily extensible by making all of the restricted members protected?

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions