title: How to dispose of Serilog 2.0 correctly in ASP.NET Core application?
body: <p>According to <a href="https://github.com/serilog/serilog/wiki/2.x-Upgrade-Guide" rel="noreferrer">documentation</a>, when an application is shutting down, it is recommended to dispose of Serilog using either</p>
  
  <pre><code> Log.CloseAndFlush();
  </code></pre>
  
  <p>or in case you have an instance variable to <code>.CreateLogger()</code>, call its</p>
  
  <pre><code>.Dispose();
  </code></pre>
  
  <p>When building ASP.NET Core app in Visual Studio, it generates <code>Program</code> and <code>Startup</code> classes, neither of which implements <code>IDisposable</code>. Are we supposed to add this interface to <code>Program</code> so that we have a way to dispose Serilog directly?</p>