title: Configuration of log4j2 Thread Context
body: <p>In my spring boot application I'm using log4j2. It's a typical web application. I have many connection and I want to separate logs for each connection. </p>
  
  <p>I want to use <a href="https://logging.apache.org/log4j/2.x/manual/thread-context.html" rel="nofollow noreferrer">Thread Context</a>:</p>
  
  <pre><code>@RequestMapping(value = "/test", method = RequestMethod.GET)
  public String test() throws InterruptedException
  {
      try (final CloseableThreadContext.Instance ctc = CloseableThreadContext.push(UUID.randomUUID().toString()))
      {
  
          logger.info("start");
          Thread.sleep(1000);
          logger.info("end.");
      }
      return "response";
  }
  </code></pre>
  
  <p>I'm testing in two terminals:<code>curl localhost:8000/test</code>. But I have the result:</p>
  
  <pre><code>14:09:27.895 [qtp401792389-21] INFO  Controllers.ContentController - start
  14:09:28.062 [qtp401792389-19] INFO  Controllers.ContentController - start
  14:09:28.896 [qtp401792389-21] INFO  Controllers.ContentController - end.
  14:09:29.062 [qtp401792389-19] INFO  Controllers.ContentController - end.
  </code></pre>
  
  <p>It's mix of sessions, i want this:</p>
  
  <pre><code>14:09:27.895 [qtp401792389-21] INFO  Controllers.ContentController - start
  14:09:28.896 [qtp401792389-21] INFO  Controllers.ContentController - end.
  14:09:28.062 [qtp401792389-19] INFO  Controllers.ContentController - start
  14:09:29.062 [qtp401792389-19] INFO  Controllers.ContentController - end.
  </code></pre>
  
  <p>So, is there any special configuration for this?</p>