title: NLog EventProperties in .NET Core
body: <p>I'm using <code>ILogger&lt;MyController&gt;</code> to write logs using DI (see <a href="https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-2" rel="nofollow noreferrer">step 6</a>)</p>
  
  <p>I'm also using <a href="https://github.com/NLog/NLog/wiki/EventProperties-Layout-Renderer" rel="nofollow noreferrer">NLog EventProperties</a></p>
  
  <p>I want to add traceId to all my logs in my controller automatically.</p>
  
  <p>This is working:</p>
  
  <pre><code>logger.Info("Some log. TraceId:{traceId}", 123);
  </code></pre>
  
  <p>However, then I need to change all my log commands (a lot of them!), which is a pain.</p>
  
  <p>If I do the following, it's not tread safe:</p>
  
  <pre><code>using NLog;
  public class MyController : Controller
  {
      private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
      public MyConstructor(Apilog apilog)
      {
          Logger.SetProperty("traceid", apilog.TraceId);
      }
  }
  </code></pre>
  
  <p>Is there some way to use SetProperty with <code>ILogger&lt;MyController&gt;</code>?</p>
  
  <p>Or some way of using NLog with SetProperty in a fast and thread safe way?</p>
  
  <p>Many thanks in advance!</p>