How should Serilog be configured if you want to use it within NetCore and a generic Host (or IHost), not a WebHost or something else?
There are the two options I found:
- Use
.UseSerilog()from theSerilog.Extensions.HostingNuGet package:
var host = Host.CreateDefaultBuilder()
.UseSerilog()
.UseSystemd()
.UseWindowsService()
.Build();
- Use
.ConfigureLogging()and.AddSerilog()from theSerilogNuGet package:
.ConfigureLogging(
logging =>
{
logging.AddSerilog();
});
So there are two questions now:
- Do both options result in the same behaviour and if not, what's the difference?
- Which method should be used preferred (Or are they equal and you can use as you like)?