title: Serilog with Asp.net Web Api not using enricher
body: <p>I have a Microsoft Asp.Net Web Api project, in which I am attempting to setup serilog logging. I have installed the Nuget packages for Serilog, Serilog.Sinks.File, SerilogWeb.Classic, and SerilogWeb.Classic.WebApi. Note, that I am NOT able to use .Net Core. </p>
  
  <p>My problem is that I am attempting to use the enrichers from the SerilogWeb.CLassic.WebApi package, but they aren't changing my output. I am sure that what I am doing is a simple mistake, but I cannot find any examples of others using this same enricher online (everything I find is on .Net Core). </p>
  
  <pre><code>Log.Logger = new LoggerConfiguration()
      .Enrich.WithWebApiActionName()
      .WriteTo.File("D:/mytestresults.txt")
      .CreateLogger();
  </code></pre>
  
  <p>The code snippet above is from my Startup.cs file. When I run the http requests are logged to the file, but adding and removing the Enrich line makes no difference. Below is a sample file output</p>
  
  <pre><code>2019-03-26 10:09:11.215 -04:00 [INF] HTTP GET /api/actions/ responded 200 in 17ms
  2019-03-26 10:09:13.621 -04:00 [INF] HTTP GET /api/actions/ responded 200 in 9ms
  </code></pre>
  
  <p>Note, that I do want to use other enrichers, but I have simplified this down some for figuring out what I am doing wrong. </p>
  
  <p>For clarity about the packages that I am using, the following is some of my packages.config</p>
  
  <pre><code>&lt;package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net461" /&gt;
  &lt;package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net461" /&gt;
  &lt;package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net461" /&gt;
  &lt;package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net461" /&gt;
  &lt;package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net461" /&gt;
  &lt;package id="Serilog" version="2.8.0" targetFramework="net461" /&gt;
  &lt;package id="Serilog.Sinks.File" version="4.0.0" targetFramework="net461" /&gt;
  &lt;package id="Serilog.Sinks.MSSqlServer" version="5.1.2" targetFramework="net461" /&gt;
  &lt;package id="Serilog.Sinks.PeriodicBatching" version="2.1.1" targetFramework="net461" /&gt;
  &lt;package id="SerilogWeb.Classic" version="5.0.48" targetFramework="net461" /&gt;
  &lt;package id="SerilogWeb.Classic.WebApi" version="4.0.5" targetFramework="net461" /&gt;
  </code></pre>
  
  <hr>
  
  <p>EDIT</p>
  
  <p>The following is my code after changes suggested, and while some enrichers are working, I am not getting the action and controller names:</p>
  
  <pre><code>        Log.Logger = new LoggerConfiguration()
          .Enrich.FromLogContext()
          .Enrich.WithUserName()
          .Enrich.WithWebApiRouteData()
          .Enrich.WithWebApiControllerName()
          .Enrich.WithWebApiRouteTemplate()
          .Enrich.WithWebApiActionName()
          .Enrich.WithHttpRequestUrl()
          .WriteTo.MSSqlServer(connectionString, tableName, restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Information, autoCreateSqlTable: true)
          .WriteTo.File("D:/mynewlog.txt", outputTemplate: "&lt;{WebApiAction}&gt; Time: {Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} Level:[{Level:u3}] Message:{Message:lj}Properties:{Properties}{NewLine}{Exception}")
          .CreateLogger();
  </code></pre>
  
  <p>The following is what is being logged to the file at this point (sql is the same)</p>
  
  <pre><code>&lt;&gt; Time: 2019-03-27 10:34:47.842 -04:00 Level:[INF] Message:HTTP GET /api/actions/reviews responded 200 in 7msProperties:{ SourceContext: "SerilogWeb.Classic.ApplicationLifecycleModule", UserName: "theUsernameWasHere", HttpRequestUrl: "http://localhost:61111/api/actions/reviews" }
  </code></pre>