title: Сan't configure a custom sink for a serilog
body: <p>I can't connect the custom sink to the logger via the configuration file. I tried under .Net 5 and .Net Core 3.1.</p>
  <p>I studied the documentation:
  <a href="https://github.com/serilog/serilog-settings-configuration#using-section-and-auto-discovery-of-configuration-assemblies" rel="nofollow noreferrer">https://github.com/serilog/serilog-settings-configuration#using-section-and-auto-discovery-of-configuration-assemblies</a></p>
  <p>I also saw responses to an identical request.
  <a href="https://stackoverflow.com/a/50118486/13151982">https://stackoverflow.com/a/50118486/13151982</a>
  <a href="https://stackoverflow.com/a/24922105/13151982">https://stackoverflow.com/a/24922105/13151982</a></p>
  <p>But for some reason, this does not work for me.</p>
  <p>To reproduce the problem, I made a minimalistic application. Also does not work, as in my main project.</p>
  <p>SampleApp.csproj:</p>
  <pre><code>&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;
  
    &lt;PropertyGroup&gt;
      &lt;OutputType&gt;Exe&lt;/OutputType&gt;
      &lt;TargetFramework&gt;netcoreapp3.1&lt;/TargetFramework&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include=&quot;Microsoft.Extensions.Hosting&quot; Version=&quot;5.0.0&quot; /&gt;
      &lt;PackageReference Include=&quot;Serilog.Extensions.Hosting&quot; Version=&quot;4.1.2&quot; /&gt;
      &lt;PackageReference Include=&quot;Serilog.Settings.Configuration&quot; Version=&quot;3.1.0&quot; /&gt;
      &lt;PackageReference Include=&quot;Serilog.Sinks.Console&quot; Version=&quot;3.1.1&quot; /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;None Update=&quot;appsettings.json&quot;&gt;
        &lt;CopyToOutputDirectory&gt;Always&lt;/CopyToOutputDirectory&gt;
      &lt;/None&gt;
    &lt;/ItemGroup&gt;
  
  &lt;/Project&gt;
  
  </code></pre>
  <p>Simple custom sink:</p>
  <pre><code>    public class SerilogCounterSink : ILogEventSink
      {
          private static int i = 0;
  
          public void Emit(LogEvent logEvent)
          {
              i++;
          }
      }
  </code></pre>
  <p>Configuration:</p>
  <pre><code>var builder = new ConfigurationBuilder();
              ConfigSetup(builder);
  
              // defining Serilog configs
              Log.Logger = new LoggerConfiguration()
                  .ReadFrom.Configuration(builder.Build())
                  .Enrich.FromLogContext()
                  .WriteTo.Console()
                  //.WriteTo.Sink(new SerilogCounterSink())  //works if uncomment this line
                  .CreateLogger();
              
              // Initiated the denpendency injection container 
              var host = Host.CreateDefaultBuilder()
                          .ConfigureServices((context, services) =&gt; {
                              services.AddTransient&lt;IDataService, DataService&gt;();
                          })
                          .UseSerilog()
                          .Build();
  </code></pre>
  <p>Configuration via file:</p>
  <pre><code>&quot;Serilog&quot;: {
      &quot;Using&quot;: [ &quot;SampleApp&quot; ],
      &quot;WriteTo&quot;: [
        { &quot;Name&quot;: &quot;SerilogCounterSink&quot; },
        { &quot;Name&quot;: &quot;Console&quot; },
        {
          &quot;Name&quot;: &quot;File&quot;,
          &quot;Args&quot;: { &quot;path&quot;: &quot;Logs/log.txt&quot; }
        }
      ],
      &quot;MinimalLevel&quot;: {
        &quot;Default&quot;: &quot;Information&quot;,
        &quot;Override&quot;: {
          &quot;System&quot;: &quot;Warning&quot;,
          &quot;Microsoft&quot;: &quot;Information&quot;
        }
      }
    }
  </code></pre>
  <p>I tried like this:</p>
  <pre><code>    &quot;WriteTo&quot;: [
        { &quot;Name&quot;: &quot;SampleApp.SerilogCounterSink&quot; },
  
      &quot;WriteTo&quot;: [
        { &quot;Name&quot;: &quot;SerilogCounter&quot; },
  
      &quot;WriteTo&quot;: [
        { &quot;Name&quot;: &quot;SampleApp.SerilogCounter&quot; },
  
  </code></pre>
  <p>As a result, when writing</p>
  <pre><code>_log.LogInformation(&quot;test&quot;);
  </code></pre>
  <p>I do not get into the SerilogCounterSink.Emit (put a breakpoint there). If i uncomment a line of code where a custom sink is added programmatically, then everything works - I get into the method.</p>