title: How to override Serilog minimum level by a custom property
body: <p>I'm using Serilog with a pretty basic config.</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;Serilog&quot;: {
      &quot;MinimumLevel&quot;: {
        &quot;Default&quot;: &quot;Information&quot;,
        &quot;Override&quot;: {
          &quot;MyApp.SomeNoisyCode&quot;: &quot;Warning&quot;
        }
    }
  }
  </code></pre>
  <p>The <code>SomeNoisyCode</code> runs every second so I only want to see warnings and errors. My problem is that the noisy code uses other code that also logs information events. For example EntityFrameworkCore.</p>
  <blockquote>
  <p>[11:22:27 INF] Executed DbCommand (1ms) ...<br />
  [11:22:28 INF] Executed DbCommand (3ms) ...<br />
  [11:22:29 INF] Executed DbCommand (2ms) ...<br />
  [11:22:30 INF] Executed DbCommand (4ms) ...</p>
  </blockquote>
  <p>Again I just want to see warnings and errors from DbCommand, but only within the context of the noisy code.</p>
  <p>This config would hide too much. I still want to receive Information logs from other source contexts.</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;Serilog&quot;: {
      &quot;MinimumLevel&quot;: {
        &quot;Default&quot;: &quot;Information&quot;,
        &quot;Override&quot;: {
          &quot;MyApp.SomeNoisyCode&quot;: &quot;Warning&quot;,
          &quot;Microsoft.EntityFrameworkCore.Database.Command&quot;: &quot;Warning&quot;
        }
    }
  }
  </code></pre>
  <p>I need a way to override the log level of all loggers in the scope of my noisy code. I think I can do this by creating a log scope.</p>
  <pre class="lang-cs prettyprint-override"><code>// In SomeNoisyCode.cs
  using var logScope = _logger.BeginScope(
          new Dictionary&lt;string, object?&gt;
          {
              [&quot;RootSourceContext&quot;] = GetType()?.FullName
          });
  
  </code></pre>
  <p>Now what do I have to put in my Serilog config to override the MinimumLevel to <code>&quot;Warning&quot;</code> or <code>&quot;Error&quot;</code> based on the value of the <code>RootSourceContext</code> property?</p>