Microsoft.AspNetCore.Diagnostics.Middleware 8.4.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Microsoft.AspNetCore.Diagnostics.Middleware --version 8.4.0
NuGet\Install-Package Microsoft.AspNetCore.Diagnostics.Middleware -Version 8.4.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="Microsoft.AspNetCore.Diagnostics.Middleware" Version="8.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.AspNetCore.Diagnostics.Middleware --version 8.4.0
#r "nuget: Microsoft.AspNetCore.Diagnostics.Middleware, 8.4.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.
// Install Microsoft.AspNetCore.Diagnostics.Middleware as a Cake Addin
#addin nuget:?package=Microsoft.AspNetCore.Diagnostics.Middleware&version=8.4.0

// Install Microsoft.AspNetCore.Diagnostics.Middleware as a Cake Tool
#tool nuget:?package=Microsoft.AspNetCore.Diagnostics.Middleware&version=8.4.0

Microsoft.AspNetCore.Diagnostics.Middleware

HTTP request diagnostics middleware for tracking latency and enriching and redacting log output.

Install the package

From the command-line:

dotnet add package Microsoft.AspNetCore.Diagnostics.Middleware

Or directly in the C# project file:

<ItemGroup>
  <PackageReference Include="Microsoft.AspNetCore.Diagnostics.Middleware" Version="[CURRENTVERSION]" />
</ItemGroup>

Usage Example

Tracking HTTP Request Latency

These components enable tracking and reporting the latency of HTTP request processing.

The services can be registered using the following methods:

public static IServiceCollection AddRequestCheckpoint(this IServiceCollection services)
public static IServiceCollection AddRequestLatencyTelemetry(this IServiceCollection services)
public static IServiceCollection AddRequestLatencyTelemetry(this IServiceCollection services, Action<RequestLatencyTelemetryOptions> configure)
public static IServiceCollection AddRequestLatencyTelemetry(this IServiceCollection services, IConfigurationSection section)

The middleware can be registered using the following methods:

public static IApplicationBuilder UseRequestCheckpoint(this IApplicationBuilder builder)
public static IApplicationBuilder UseRequestLatencyTelemetry(this IApplicationBuilder builder)

For example:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRequestLatencyTelemetry();
builder.Services.AddRequestCheckpoint(options => { });

var app = builder.Build();

app.UseRequestCheckpoint();
app.UseRequestLatencyTelemetry();

HTTP Request Logs Enrichment and Redaction

These components enable enriching and redacting ASP.NET Core's HTTP request logs.

These APIs are only available for ASP.NET Core 8+.

The services can be registered using the following methods:

public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection services, Action<HeaderParsingOptions>? configure = null)
public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection services, IConfigurationSection section)
public static IServiceCollection AddHttpLogEnricher<T>(this IServiceCollection services)

The middleware can be registered using the following method:

public static IApplicationBuilder UseHttpLogging(this IApplicationBuilder builder)

For example:

var builder = WebApplication.CreateBuilder(args);

// General logging options
builder.Services.AddHttpLogging(options => { });
// Redaction options
builder.Services.AddHttpLoggingRedaction(options => { });

var app = builder.Build();

app.UseHttpLogging();

Feedback & Contributing

We welcome feedback and contributions in our GitHub repo.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Microsoft.AspNetCore.Diagnostics.Middleware:

Package Downloads
WC.Library.Web

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
9.0.0-preview.3.24209.3 57 4/11/2024
9.0.0-preview.2.24157.4 58 3/12/2024
9.0.0-preview.1.24108.1 74 2/13/2024
8.4.0 321 4/9/2024
8.3.0 503 3/12/2024
8.2.0 768 2/13/2024
8.1.0 1,135 1/9/2024
8.0.0 1,260 11/14/2023