How to print http status in logs with springboot logback

733 views Asked by At

I am trying to print http status code in the log statement using spring boot log. But I do not know the pattern to print that. I used statusCode, status etc but doesnt work. Pls advise is there a way I can have status also printed in the logs for exception. Implementation is

log.error(e.getMessage(), e);

Logback xml

<appender name="json.stdout" class="ch.qos.logback.core.ConsoleAppender">
            <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
                <providers>
                    <pattern>
                        <pattern>
                            {
                             "level": "%level",
                            "logger": "%logger{36}",
                            "message": "%message",
                            "stack":"%exception"
                            }
                        </pattern>
                    </pattern>
                </providers>
            </encoder>
        </appender>
0

There are 0 answers