title: Logging to Console with DI in C#
body: <p>in this short sample, if I keep just the <code>.AddConsole()</code>  in <code>ConfigureServices</code> nothing gets logged to console regardless of the LogLevel, but if I add <code>.AddConsole().AddDebug()</code> all messages get logged to Console 3 times! What am I missing? Thanks!</p>
  
  <pre><code>namespace samples
  {
      using System;
      using Microsoft.Extensions.DependencyInjection;
      using Microsoft.Extensions.Logging;
  
      public class Program
      {    
          public static void Main(string[] args)
          {
              var serviceCollection = new ServiceCollection();
              ConfigureServices(serviceCollection);
              var serviceProvider = serviceCollection.BuildServiceProvider();
  
              var app = serviceProvider.GetService&lt;Application&gt;();
              app.Run();
          }
  
          private static void ConfigureServices(IServiceCollection services)
          {
              // Add Logger
              services.AddLogging(configure =&gt; configure.AddConsole().AddDebug());
  
              // Register Application
              services.AddTransient&lt;Application&gt;();
          }
      }
  
      public class Application {
          private readonly ILogger logger;
  
          public Application(ILogger&lt;Application&gt; logger)
          {
              this.logger = logger;
              this.logger.LogInformation("In Application::ctor");
          }
  
          public void Run() 
          {
              this.logger.LogInformation("Info: In Application::Run");
              this.logger.LogWarning("Warn: In Application::Run");
              this.logger.LogError("Error: In Application::Run");
              this.logger.LogCritical("Critical: In Application::Run");
          }
      }
  }
  
  </code></pre>
  
  <p>And this is what gets displayed for each Log*() call:</p>
  
  <pre><code>fail: samples.Application[0]
        Error: In Application::Run
  samples.Application: Error: Error: In Application::Run
  </code></pre>
  
  <p><strong>Update/Solution</strong>
  Thanks @panoskarajohn for figuring this out. App.Run() needed to be an async:
  Change <code>app.Run(); =&gt; Task.Run(() =&gt; app.Run()).Wait();</code>
  <code>public void Run() =&gt; public async Task Run()</code>
  And should work without debugging() option
  I cannot find anything on why this happens</p>
  
  <p>Anyone knows why?</p>