Skip to content
Discussion options

You must be logged in to vote

Instead of the message provider, you can use the pattern provider with #tryJson{...}

<pattern>
    {
        "msg": "#tryJson{%message}"
    }
</pattern>

Note that this will add a lot of overhead to your logging, since it tries to format every message as JSON (and if it fails, it falls back to logging it as a string)

If high performance is a requirement, you could write your own custom JsonProvider implementation that optimizes it. For example, if you know a specific Logger always logs messages in proper JSON format, then you could do something like this:

public class MyJsonProvider extends AbstractJsonProvider<ILoggingEvent> {

    @Override
    public void writeTo(JsonGenerator generator, 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by philsttr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants