Closed nblumhardt closed 6 years ago
The documentation suggests that for aspnet core 2.0 to configuring Serilog in the CreateServices section, however, the newer way to do this is in the BuildWebHost configuration.
For example:
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.AddSerilog();
})
.UseStartup<Startup>()
.Build();
Perhaps the documentation should be updated.
Actually, the documentation is contradictory, in one place it says to use .UseSerilog() and in another it says to use .AddSerilog().
ie:
ASP.NET Core 2.0+ Instructions ASP.NET Core 2.0 applications should prefer Serilog.AspNetCore and UseSerilog() instead.
and
Finally, for .NET Core 2.0+, in your Startup class's Configure() method, remove the existing logger configuration entries and call AddSerilog() on the provided loggingBuilder.
I should note that despite it saying ".NET Core" vs "ASP.NET Core", it's still referring to the IHostingEnvironment and log entry examples indicate it's asp.net.
The code and docs at https://github.com/serilog/serilog-aspnetcore have had a few updates since this ticket was raised; closing.
Install Serilog.AspNetCore
package and include it in your program file, to use UseSerilog()
.
From #98. List to be constructed: