You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.NET 6 includes a middleware implementation that captures HTTP request context as LogEvent Properties.
Use the LoggingFields-property to control how much data to capture in the logging. Notice RequestBody and ResponseBody has performance implications, as it requires buffering the entire body.
The logger category-name become Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware
Notice the Microsoft HttpLoggingMiddleware outputs both a request-LogEvent and response-LogEvent for each HttpRequest. This can be changed to a single logevent by setting the option CombineLogs = true.
Notice the Microsoft HttpLoggingMiddleware will react to all requests (including .css + .js). These can be filtered away by using IHttpLoggingInterceptor
Note to include the HTTP Request Duration, then one can use ${aspnet-request-duration} that outputs total milliseconds. See also NLog.Web.AspNetCore LayoutRenderers
Note to include the HTTP Posted Body, then one can use ${aspnet-request-posted-body} together with NLogRequestPostedBodyMiddleware.
Request Logging HttpModule introduced with NLog5
Install NLog.Web nuget-package for classic ASP.NET and activate like this (Global.asax)
Note to include the HTTP Request Duration, then one can use ${aspnet-request-duration} that outputs total milliseconds. See also NLog.Web LayoutRenderers
Note to include the HTTP Posted Body, then one can use ${aspnet-request-posted-body} together with NLogRequestPostedBodyModule.