Add StructuredLogFormatter wrapper for JsonEncoder (logback) #210
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.
Hi, I wanted to be able to use the JsonEncoder for Logback natively with SpringBoot, but for now I always have to create a
logback.xml
. SpringBoot 3.4 introduced support for structured formatting, without the need to write logback.xml / log4j.xml.To support his, I created a simple wrapper. Then user will be able to use the encoder as a formatter for structured logging with just a regular
application.properties
/.yaml
, like this:Let me know what you think. In our application, I've created a similar wrapper, but since
JsonEncoder
does not expose thegetJson(event)
method, it's a little bit cumbersome -- I had to use reflection. I didn't want to use the publicencode(event)
because I'd need to decode it right back using UTF-8 into aString
instance, every time.Alternatively, if you could expose the
JsonEncoder.getJson(event)
method (or a new one, returning JSON as String), that'd help us a lot as well. I know this commit drags with itself a dependency on SpringBoot, which might not be ideal.