This middleware allows for logging of requests and responses in ASP.NET Core applications.
Install-Package AspNetCore.RequestResponseLoggingMiddleware
app.UseRequestResponseLogging(ctx =>
{
var path = ctx.Request.Path;
return path.StartsWithSegments("/needs-to-be-logged", StringComparison.InvariantCultureIgnoreCase);
});
app.UseRouting();
Note that app.UseRequestResponseLogging()
should be called as early as possible.