title: How to create a LoggerFactory with a ConsoleLoggerProvider?
body: <p>The <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.console.consoleloggerprovider" rel="noreferrer">ConsoleLoggerProvider</a> has four constructors:</p>
  
  <ol>
  <li><code>ConsoleLoggerProvider(IConsoleLoggerSettings)</code></li>
  <li><code>ConsoleLoggerProvider(IOptionsMonitor&lt;ConsoleLoggerOptions&gt;)</code></li>
  <li><code>ConsoleLoggerProvider(Func&lt;String,LogLevel,Boolean&gt;, Boolean)</code></li>
  <li><code>ConsoleLoggerProvider(Func&lt;String,LogLevel,Boolean&gt;, Boolean, Boolean)</code></li>
  </ol>
  
  <p>Three of them are declared obsolete with this message:</p>
  
  <blockquote>
    <p>This method is obsolete and will be removed in a future version. The recommended alternative is using LoggerFactory to configure filtering and ConsoleLoggerOptions to configure logging options.</p>
  </blockquote>
  
  <p>With constructor #3, creating a <code>LoggerFactory</code> with a <code>ConsoleLoggerProvider</code> is straightforward (as documented on <a href="https://docs.microsoft.com/en-us/ef/core/miscellaneous/logging" rel="noreferrer">Entity Framework Core - Logging</a>):</p>
  
  <pre class="lang-cs prettyprint-override"><code>var loggerFactory = new LoggerFactory(new[] { new ConsoleLoggerProvider((category, level) =&gt; level &gt;= LogLevel.Information, true) });
  </code></pre>
  
  <p>But since it's deprecated, we are left with constructor #2. Here's what I found to be equivalent:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var configureNamedOptions = new ConfigureNamedOptions&lt;ConsoleLoggerOptions&gt;("", null);
  var optionsFactory = new OptionsFactory&lt;ConsoleLoggerOptions&gt;(new []{ configureNamedOptions }, Enumerable.Empty&lt;IPostConfigureOptions&lt;ConsoleLoggerOptions&gt;&gt;());
  var optionsMonitor = new OptionsMonitor&lt;ConsoleLoggerOptions&gt;(optionsFactory, Enumerable.Empty&lt;IOptionsChangeTokenSource&lt;ConsoleLoggerOptions&gt;&gt;(), new OptionsCache&lt;ConsoleLoggerOptions&gt;());
  var loggerFactory = new LoggerFactory(new[] { new ConsoleLoggerProvider(optionsMonitor) }, new LoggerFilterOptions { MinLevel = LogLevel.Information });
  </code></pre>
  
  <p>This seems overly complicated, am I missing something simpler?</p>