title: Serilog: Missing logs when logging with simple for loop
body: <p>I have started using Serilog and written test <em>Dot Net Core 3.1 Console application</em>.</p>
  
  <p>In my simple project, I am looping and logging. Serilog logs on <em>Console</em> and <em>File</em>.</p>
  
  <p>But I found that logs are getting missed after 10,000 log entries. Till 10,000 log entries, all logs are sequences in both Console and File, but after 10,000 entries, logs starting to miss on both <em>Console</em> and <em>File</em>. For example, 29483 after 10000.</p>
  
  <p>Also, function call Log.CloseAndFlush() to flush all logs isn't working as i don't see log entry "FINISHED" in the end of <em>Console</em> and <em>File</em>.</p>
  
  <pre><code>2020-05-26 12:12:38.575 | [INFO] | Thread-1 | hello:1
  ........ Logs are in sequencial order ........
  2020-05-26 12:12:38.575 | [INFO] | Thread-1 | hello:9993
  2020-05-26 12:12:38.575 | [INFO] | Thread-1 | hello:9994
  2020-05-26 12:12:38.575 | [INFO] | Thread-1 | hello:9995
  2020-05-26 12:12:38.575 | [INFO] | Thread-1 | hello:9996
  2020-05-26 12:12:38.575 | [INFO] | Thread-1 | hello:9997
  2020-05-26 12:12:38.575 | [INFO] | Thread-1 | hello:9998
  2020-05-26 12:12:38.575 | [INFO] | Thread-1 | hello:9999
  2020-05-26 12:12:38.575 | [INFO] | Thread-1 | hello:10000
  2020-05-26 12:12:38.637 | [INFO] | Thread-1 | hello:29483
  2020-05-26 12:12:38.689 | [INFO] | Thread-1 | hello:62627
  2020-05-26 12:12:38.693 | [INFO] | Thread-1 | hello:64740
  2020-05-26 12:12:38.694 | [INFO] | Thread-1 | hello:65624
  2020-05-26 12:12:38.695 | [INFO] | Thread-1 | hello:66169
  2020-05-26 12:12:38.697 | [INFO] | Thread-1 | hello:66662
  2020-05-26 12:12:38.697 | [INFO] | Thread-1 | hello:67040
  2020-05-26 12:12:38.698 | [INFO] | Thread-1 | hello:67432
  2020-05-26 12:12:38.698 | [INFO] | Thread-1 | hello:67828
  2020-05-26 12:12:38.699 | [INFO] | Thread-1 | hello:68083
  2020-05-26 12:12:38.700 | [INFO] | Thread-1 | hello:68386
  2020-05-26 12:12:38.700 | [INFO] | Thread-1 | hello:68756
  2020-05-26 12:12:38.701 | [INFO] | Thread-1 | hello:69387
  2020-05-26 12:12:38.702 | [INFO] | Thread-1 | hello:69904
  2020-05-26 12:12:38.703 | [INFO] | Thread-1 | hello:70296
  2020-05-26 12:12:38.703 | [INFO] | Thread-1 | hello:70681
  2020-05-26 12:12:38.704 | [INFO] | Thread-1 | hello:71093
  2020-05-26 12:12:38.706 | [INFO] | Thread-1 | hello:72488
  2020-05-26 12:12:38.706 | [INFO] | Thread-1 | hello:72945
  2020-05-26 12:12:38.707 | [INFO] | Thread-1 | hello:73590
  2020-05-26 12:12:38.708 | [INFO] | Thread-1 | hello:73975
  2020-05-26 12:12:38.708 | [INFO] | Thread-1 | hello:74383
  2020-05-26 12:12:38.709 | [INFO] | Thread-1 | hello:74783
  2020-05-26 12:12:38.709 | [INFO] | Thread-1 | hello:75183
  2020-05-26 12:12:38.711 | [INFO] | Thread-1 | hello:75644
  2020-05-26 12:12:38.712 | [INFO] | Thread-1 | hello:76087
  2020-05-26 12:12:38.713 | [INFO] | Thread-1 | hello:76719
  </code></pre>
  
  <p>I was looking at issues faced by other developers on missing logs but none of them relates to my issue.</p>
  
  <p><strong>Program.cs</strong></p>
  
  <pre><code>using Microsoft.Extensions.Configuration;
  using Serilog;
  using Serilog.Core;
  using System;
  
  namespace MyApp
  {
      public class Program
      {
          static void Main(string[] args)
          {
              var l_config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
  
              Logger l_log = new LoggerConfiguration().ReadFrom.Configuration(l_config).CreateLogger();
              Log.Logger = l_log;
  
              for (long l_index = 0; l_index &lt; 100000L; l_index++)
              {
                  Log.Information("hello:" + l_index);
              }
              Log.Information("FINISHED");
              Log.CloseAndFlush();
              Console.ReadKey();
          }
  
          ~Program()
          {
              Log.CloseAndFlush();
          }
      }
  }
  </code></pre>
  
  <p><strong>appsettings.json</strong></p>
  
  <pre><code>{
      "Serilog": {
          "Using": ["Serilog.Sinks.Console"],
          "MinimumLevel": "Debug",
          "WriteTo": [{
                  "Name": "Async",
                  "Args": {
                      "configure": [{
                              "Name": "Console",
                              "Args": {
                                  "MinimumLevel": "Verbose",
                                  "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} | [{Level:u4}] | Thread-{ThreadId} | {Message:lj}{NewLine}{Exception}"
                              }                           
                          }, {
                              "Name": "File",
                              "Args": {
                                  "MinimumLevel": "Verbose",
                                  "path": "Logs\\log..txt",                               
                                  "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} | [{Level:u4}] | Thread-{ThreadId} | {Message:lj}{NewLine}{Exception}",
                                  "rollingInterval": "Hour",
                              }
                          }
                      ]
                  }
              }
          ],
          "Enrich": ["FromLogContext", "WithThreadId"],
          "Destructure": [{
                  "Name": "ToMaximumDepth",
                  "Args": {
                      "maximumDestructuringDepth": 4
                  }
              }, {
                  "Name": "ToMaximumStringLength",
                  "Args": {
                      "maximumStringLength": 100
                  }
              }, {
                  "Name": "ToMaximumCollectionCount",
                  "Args": {
                      "maximumCollectionCount": 10
                  }
              }
          ],
          "Properties": {
              "Application": "MyApp"
          }
      }
  }
  </code></pre>
  
  <p>Using Nuget packages:</p>
  
  <ul>
  <li>Serilog.dll</li>
  <li>Serilog.Enrichers.Environment.dll</li>
  <li>Serilog.Enrichers.Thread.dll</li>
  <li>Serilog.Settings.Configuration.dll</li>
  <li>Serilog.Sinks.Async.dll</li>
  <li>Serilog.Sinks.Console.dll</li>
  </ul>
  
  <p>I apologize for putting lot of info here but that's needed so we can pin point the issue.</p>