Problems configuring latest Serilog from appSettings.json

57 Views Asked by At

I am using Serilog and getting the configuration from the appsettings.json file. I need to update the following code, which worked with an earlier version of the Serilog library but does not work with the latest version.

var configuration = new ConfigurationBuilder()
     .SetBasePath(Directory.GetCurrentDirectory())
     .AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true)
     .Build();
var logger = new LoggerConfiguration()
     .ReadFrom.Configuration(configuration)
     .CreateLogger();

The method call ReadFrom.Configuration is not available with the latest Serilog library. Is there a way to set the configuration from the Json file?

0

There are 0 best solutions below