If I create a new ASP.NET Core Web App (Model-View-Controller) with dotnet new mvc it has already logging configured out of the box.
However, http request error codes are logged as info event.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET https://localhost:5001/doesnotexists
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 4.4052ms 404
Is it possible to changed this behaviour to (4xx -> warning, 5xx -> error) .i.e by investigating and rewriting log events.
I already read https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.2
this looked promissing but I didn't find a hook for this purpose
var webHost = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureLogging((hostingContext, logging) =>
{
// investigate and rewrite log event
})
.UseStartup<Startup>()
.Build()