title: How to log in JSON with Logback?
body: <p>I'm new to SLF4J and Logback and I'm trying to log every request and response of API following this <a href="https://pivotal.io/de/application-transformation-recipes/observability/request-response-logging-in-spring-boot" rel="nofollow noreferrer">link</a>. Here's the configuration </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;configuration&gt;
      &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;%requestURL | status code: %statusCode | bytes: %bytesSent | elapsed time: %elapsedTime | request-log: %magenta(%requestContent) | response-log: %cyan(%responseContent)&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
      &lt;appender-ref ref="STDOUT"/&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Currently it's printing:</p>
  
  <pre><code>GET /api/request HTTP/1.1 | status code: 200 | bytes: 599 | elapsed time: 2630 | request-log:  | response-log {"key1":"field1","key2":"field2"}
  </code></pre>
  
  <p>And I want to log something like:</p>
  
  <pre><code>{
      "url": "GET /api/request HTTP/1.1",
      "status": 200,
      "elapsed_time": 2630 ,
      "response": {
          "key1":"value1",
          "key2":"value2"
      }
  }
  </code></pre>