I'm new to SLF4J and Logback and I'm trying to log every request and response of API following this link. Here's the configuration
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%requestURL | status code: %statusCode | bytes: %bytesSent | elapsed time: %elapsedTime | request-log: %magenta(%requestContent) | response-log: %cyan(%responseContent)</pattern>
</encoder>
</appender>
<appender-ref ref="STDOUT"/>
</configuration>
Currently it's printing:
GET /api/request HTTP/1.1 | status code: 200 | bytes: 599 | elapsed time: 2630 | request-log: | response-log {"key1":"field1","key2":"field2"}
And I want to log something like:
{
"url": "GET /api/request HTTP/1.1",
"status": 200,
"elapsed_time": 2630 ,
"response": {
"key1":"value1",
"key2":"value2"
}
}