title: Filter Serilog logs to different sinks depending on context source?
body: <p>I have a .NET Core 2.0 application in which I successfully use Serilog for logging. Now, I would like to log some database performance statistics to a separate sink (they are not for debugging, which basically is the purpose of all other logging in the application, so I would like to keep them separate) and figured this could be accomplished by creating the DB statistics logger with <code>Log.ForContext&lt;MyClass&gt;()</code>.</p>
  
  <p>I do not know how I am supposed to configure Serilog <em>using my appsettings.json</em> to log my "debug logs" to one sink and my DB statistics log to another? I am hoping it is possible to do something like:</p>
  
  <pre><code>"Serilog": {
    "WriteTo": [
      {
        "Name": "RollingFile",
        "pathFormat": "logs/Log-{Date}.log",
        "Filter": {
          "ByExcluding": "FromSource(MyClass)"
        }
      },
      {
        "Name": "RollingFile",
        "pathFormat": "logs/DBStat-{Date}.log",
        "Filter": {
            "ByIncludingOnly": "FromSource(MyClass)"
        }
      }
    ]
  }
  </code></pre>
  
  <p>The <code>"Filter"</code> parts of the configuration is pure guesswork on my part. Is this possible using my configuration filer or do I need to do this in code in my <code>Startup.cs</code> file?</p>
  
  <p>EDIT: I have got it working using the C# API but would still like to figure it out using JSON config:</p>
  
  <pre><code>Log.Logger = new LoggerConfiguration()
              .WriteTo.Logger(lc =&gt; lc
                  .Filter.ByExcluding(Matching.FromSource&lt;MyClass&gt;())
                  .WriteTo.LiterateConsole())
              .WriteTo.Logger(lc =&gt; lc
                  .Filter.ByExcluding(Matching.FromSource&lt;MyClass&gt;())
                  .WriteTo.RollingFile("logs/DebugLog-{Date}.log"))
              .WriteTo.Logger(lc =&gt; lc
                  .Filter.ByIncludingOnly(Matching.FromSource&lt;MyClass&gt;())
                  .WriteTo.RollingFile("logs/DBStats-{Date}.log", outputTemplate: "{Message}{NewLine}"))
              .CreateLogger();
  </code></pre>