This is my Program.cs class

 private static void ConfigureServices(ServiceCollection services)
 {  
         var serilogLogger = new LoggerConfiguration()
           .WriteTo.File("TheCodeBuzz.txt")
           .CreateLogger();

            services.AddLogging(builder =>
            {
                builder.SetMinimumLevel(LogLevel.Information);
                builder.AddSerilog(logger: serilogLogger, dispose: true);
            });

}

And This is My MainForm.cs as I am designing a desktop application

partial class MainForm : IDisposable
{
     private readonly ILogger _logger;

     public MainForm(ILogger logger)
     {           
          _logger = logger;
     }

     private void Hello()
     {
         _logger.LogInformation("message");
     }
}

_logger.LogInformation throws a run time error i.e. An unhandled exception

0

There are 0 answers