P.S. The code below works fine. The problem was between the monitor and the chair. Answer by @jpgrassi sent me in the right direction to resolve it.
I have the following in program.cs:
public class Program {
public static void Main(string[] args) {
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseSerilog((ctx, config) => { config.ReadFrom.Configuration(ctx.Configuration); })
.UseStartup<Startup>();
}
And in appsettings.json:
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Default": "Information",
"Microsoft": "Information",
"System": "Information"
}
},
"WriteTo": [
{
"Name": "RollingFile",
"Args": {
"pathFormat": "log-{Date}.txt",
}
}
]
},
"AllowedHosts": "*"
}
In the controller, I write out a log _logger.LogWarning("foo");
, but the file is not written out anywhere, there aren't any error that I can see.
I've imported following packages from Nuget: Serilog, Serilog.AspNetCore, Serilog.Settings.Configuration, Serilog.Sinks.RollingFile.
What am I missing?