I tried to achieve the same thing as you and I got it to work with VS.Net 2020 and Serilog.
My appSettings.json looks like this:
{
"Serilog": {
"WriteTo": [
{
"Name": "Console",
"Args": {
"standardErrorFromLevel": "Error"
}
}
],
}
}
I tried this with setting command line arguments in my web projects properties, Debug, General, Launch Profiles to:
>c:\temp\stdout.log 2>c:\temp\stderr.log. And the logging gets nicely separated into these two files.
My .Net6 program.cs contains this for SeriLog:
builder.Host.UseSerilog((context, configuration) => configuration
.Enrich.FromLogContext()
.ReadFrom.Configuration(context.Configuration)
})
);
To make SeriLog the default ILogger<T> for dependency injection in controllers, I have added:
builder.Services.AddLogging(x =>
{
x.ClearProviders();
x.AddSerilog(dispose: true);
});
Might it be you are using DI and not actually be using SeriLog at all?
If you want to try and set the propeties in code, just add
.WriteTo.Async(x =>
{
x.Console(standardErrorFromLevel: LogEventLevel.Error);
}
inside UseSerilog().
I have to following SeriLog packages installed:
- Serilog.AspNetCore 4.1.0
- Serilog.Extensions.Logging 3.1.0
- SeriLog.Settings.Configuration 3.3.0
- SeriLog.Extensions.Logging.File 2.0.0
The latter should not be relevant there.