DMiddleware 5.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DMiddleware --version 5.2.0
                    
NuGet\Install-Package DMiddleware -Version 5.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DMiddleware" Version="5.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DMiddleware" Version="5.2.0" />
                    
Directory.Packages.props
<PackageReference Include="DMiddleware" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DMiddleware --version 5.2.0
                    
#r "nuget: DMiddleware, 5.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DMiddleware@5.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DMiddleware&version=5.2.0
                    
Install as a Cake Addin
#tool nuget:?package=DMiddleware&version=5.2.0
                    
Install as a Cake Tool

Request Logging Middleware

Overview

The Request Logging Middleware is an ASP.NET Core middleware designed to capture detailed information about incoming HTTP requests and their corresponding responses. It logs various metrics such as CPU usage, memory consumption, request duration, and the success status of requests. Additionally, it can save the request body, request headers, and response body to a database for further analysis.

Features

  • Logging Request Information: Captures the request method, path, and associated controller and action names.
  • Performance Metrics: Measures CPU usage, memory consumption, and thread count differences during request processing.
  • Request and Response Logging: Optionally logs request bodies, headers, and responses based on configuration settings.
  • Error Handling: Logs any exceptions thrown during request processing along with detailed error information.

How It Works

  1. The middleware measures resource usage at the start of request processing.
  2. It reads and saves the request body and headers, while also replacing the response body stream to capture the response.
  3. After processing the request, it calculates performance metrics and logs the details to the database.
  4. The middleware can be configured to save specific pieces of information based on provided options.

Configuration

To use the middleware, configure it in the Startup.cs/program.cs file as follows:

services.ConfigureDMiddlewareServices(options ⇒ new PackageConfigurationOptions() { SaveRequestBody = true, SaveRequesterInfo = true, SaveRequestHeader = true, SaveResponse = true });

Then, add the middleware in the HTTP request pipeline:

app.UseRequestLogging();

Logging Structure

The following information is logged:

  • Request Logs: Includes method, path, timestamps, CPU/memory usage, request duration, and success status.
  • Response Logs: Contains the response body if configured to save.
  • Extra Request Info Logs: Captures request bodies and headers as JSON if configured to save.
  • Error Logs: Details any exceptions thrown during the processing of the request.

Conclusion

The Request Logging Middleware provides a robust solution for monitoring and logging HTTP requests in ASP.NET Core applications. It is particularly useful for debugging, performance monitoring, and ensuring the reliability of web applications.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.0 210 12/26/2024
8.1.0 201 1/30/2025
8.0.0 188 12/26/2024
7.1.0 180 1/30/2025
7.0.0 178 12/26/2024
6.1.0 215 1/30/2025
6.0.0 186 12/26/2024
5.5.3 372 1/31/2025
5.5.2 182 1/31/2025
5.5.1 205 1/30/2025
5.5.0 218 11/21/2024
5.4.0 203 11/21/2024
5.3.0 188 11/15/2024
5.2.0 186 10/27/2024
5.1.3 182 10/26/2024
5.1.1 188 10/26/2024
5.1.0 176 10/26/2024
5.0.0 184 10/26/2024
2.1.0 188 10/22/2024
2.0.0 188 10/22/2024
Loading failed