Below is the code i'm using in program.cs
var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build();
Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(configuration) .CreateLogger();
appsettings.json-
"Serilog": { "Using": ["Serilog.Sinks.File"], "MinimumLevel": { "Default": "Information" } }, "WriteTo": [ { "Name": "File", "Args": { "path": "D\log.txt", "rollingInterval": "Day", "outputTemplate": "{Timestamp:MM/dd/yyyy}" }