title: How to correctly use slf4j MDC in spring-webflux WebFilter
body: <p>I referenced with the blog post <a href="https://simonbasle.github.io/2018/02/contextual-logging-with-reactor-context-and-mdc/" rel="noreferrer">Contextual Logging with Reactor Context and MDC</a> but I don't know how to access reactor context in WebFilter.</p>
  
  <pre><code>@Component
  public class RequestIdFilter implements WebFilter {
  
      @Override
      public Mono&lt;Void&gt; filter(ServerWebExchange exchange, WebFilterChain chain) {
          List&lt;String&gt; myHeader =  exchange.getRequest().getHeaders().get("X-My-Header");
  
          if (myHeader != null &amp;&amp; !myHeader.isEmpty()) {
              MDC.put("myHeader", myHeader.get(0));
          }
  
          return chain.filter(exchange);
      }
  }
  </code></pre>