title: How to use MDC of logback and SLF4J with spring boot to capture unique tracking in the POST request json?
body: <p>We are using:</p>
  
  <ul>
  <li>Spring Boot</li>
  <li>Slf4J</li>
  <li>Logback</li>
  <li>ELK stack </li>
  </ul>
  
  <p>Now we want to use <code>MDC</code> to add the unique tracking number, which is provided in the POST request JSON, to every log statement for a given request.</p>
  
  <p>I googled some blog posts, those are not useful for me much.</p>
  
  <p>Below is the <code>logback.xml</code> which we are using </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;configuration&gt;
      &lt;property name="PROJECT_ID" value="template-api"/&gt;
  
      &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
          &lt;encoder class="net.logstash.logback.encoder.LogstashEncoder"/&gt;
      &lt;/appender&gt;
  
      &lt;root level="INFO"&gt;
          &lt;appender-ref ref="STDOUT" /&gt;
      &lt;/root&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Can anyone provide some help on how to get this done please?</p>