dibog / cloudwatch-logback-appender

AWS Cloudwatch Logs appender for logback
Apache License 2.0
25 stars 23 forks source link

Support for message which is a json string itself. #16

Open navaneeth-spotnana opened 4 years ago

navaneeth-spotnana commented 4 years ago

Hi

My message is in itself a json string. I want the logged message to be treated as a valid json data if it's a valid json string, otherwise keep it as a normal string, like documented here.

It's a bit over my head, can you help me with a config?

navaneeth-spotnana commented 4 years ago

In other words, can I use the net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder with this appender?

vassilen commented 4 years ago

Hi, maybe a bit late answer... but you can use net.logstash.logback.layout.LoggingEventCompositeJsonLayout to achieve the same effect:

<appender name="cloudwatch" class="io.github.dibog.AwsLogAppender">
    <!-- groupName, streamName, awsConfig -->
    <layout class="net.logstash.logback.layout.LoggingEventCompositeJsonLayout">
        <providers>
            <pattern>
                <pattern>
                    {
                        "message": "%msg",
                        "level": "%level",
                        "thread": "%thread",
                        "logger": "%logger"
                    }
                </pattern>
            </pattern>
        </providers>
    </layout>
</appender>