![]() |
VOOZH | about |
dotnet add package Microsoft.AspNetCore.Diagnostics.Middleware --version 10.7.0
NuGet\Install-Package Microsoft.AspNetCore.Diagnostics.Middleware -Version 10.7.0
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.Middleware" Version="10.7.0" />
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics.Middleware" Version="10.7.0" />Directory.Packages.props
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.Middleware" />Project file
paket add Microsoft.AspNetCore.Diagnostics.Middleware --version 10.7.0
#r "nuget: Microsoft.AspNetCore.Diagnostics.Middleware, 10.7.0"
#:package Microsoft.AspNetCore.Diagnostics.Middleware@10.7.0
#addin nuget:?package=Microsoft.AspNetCore.Diagnostics.Middleware&version=10.7.0Install as a Cake Addin
#tool nuget:?package=Microsoft.AspNetCore.Diagnostics.Middleware&version=10.7.0Install as a Cake Tool
HTTP request diagnostics middleware for tracking latency and enriching and redacting log output.
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>
Provides a buffering mechanism for logs, allowing you to store logs in temporary circular buffers in memory. If the buffer is full, the oldest logs will be dropped. If you want to emit the buffered logs, you can call Flush() on the buffer. That way, if you don't flush buffers, all buffered logs will eventually be dropped and that makes sense - if you don't flush buffers, chances are
those logs are not important. At the same time, you can trigger a flush on the buffer when certain conditions are met, such as when an exception occurs.
Provides HTTP request-scoped buffering for web applications:
// Simple configuration with log level
builder.Logging.AddPerIncomingRequestBuffer(LogLevel.Warning); // Buffer Warning and lower level logs per request
// Configuration using options
builder.Logging.AddPerIncomingRequestBuffer(options =>
{
options.Rules.Add(new LogBufferingFilterRule(logLevel: LogLevel.Information)); // Buffer Information and lower level logs
options.Rules.Add(new LogBufferingFilterRule(categoryName: "Microsoft.*")); // Buffer logs from Microsoft namespaces
});
// Configuration using IConfiguration
builder.Logging.AddPerIncomingRequestBuffer(configuration.GetSection("Logging:RequestBuffering"));
Then, to flush the buffers when a bad thing happens, call the Flush() method on the injected PerRequestLogBuffer instance:
public class MyService
{
private readonly PerRequestLogBuffer _perRequestLogBuffer;
public MyService(PerRequestLogBuffer perRequestLogBuffer)
{
_perRequestLogBuffer = perRequestLogBuffer;
}
public void DoSomething()
{
try
{
// ...
}
catch (Exception ex)
{
// Flush all buffers
_perRequestLogBuffer.Flush();
}
}
}
Per-request buffering is especially useful for capturing all logs related to a specific HTTP request and making decisions about them collectively based on request outcomes. Per-request buffering is tightly coupled with Global Buffering. If a log entry is supposed to be buffered to a per-request buffer, but there is no active HTTP context, it will be buffered to the global buffer instead. If buffer flush is triggered, the per-request buffer will be flushed first, followed by the global buffer.
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();
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();
We welcome feedback and contributions in our GitHub repo.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 4 NuGet packages that depend on Microsoft.AspNetCore.Diagnostics.Middleware:
| Package | Downloads |
|---|---|
|
WC.Library.Web
Package Description |
|
|
BBT.Aether.AspNetCore
Aether is a .NET Core framework designed to provide developers with a foundational structure and pre-built cross-cutting concerns. |
|
|
BBT.Aether.HttpClient
Aether is a .NET Core framework designed to provide developers with a foundational structure and pre-built cross-cutting concerns. |
|
|
BBT.Prism.AspNetCore
Package Description |
Showing the top 3 popular GitHub repositories that depend on Microsoft.AspNetCore.Diagnostics.Middleware:
| Repository | Stars |
|---|---|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
|
mehdihadeli/food-delivery-microservices
🍔 A practical and cloud-native food delivery microservices, built with .Net Aspire, .Net 9, MassTransit, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
|
|
|
foxminchan/BookWorm
The practical implementation of Aspire using Microservices, AI-Agents
|
| Version | Downloads | Last Updated |
|---|---|---|
| 10.7.0 | 1,247 | 6/9/2026 |
| 10.6.0 | 7,025 | 5/12/2026 |
| 10.5.0 | 27,279 | 4/15/2026 |
| 10.4.0 | 13,785 | 3/10/2026 |
| 10.3.0 | 30,741 | 2/10/2026 |
| 10.2.0 | 13,378 | 1/13/2026 |
| 10.1.0 | 18,384 | 12/9/2025 |
| 10.0.0 | 184,292 | 11/11/2025 |
| 9.10.0 | 46,158 | 10/14/2025 |
| 9.9.0 | 25,182 | 9/9/2025 |
| 9.8.0 | 19,332 | 8/12/2025 |
| 9.7.0 | 8,407 | 7/8/2025 |
| 9.6.0 | 31,472 | 6/10/2025 |
| 9.5.0 | 125,480 | 5/13/2025 |
| 9.4.0 | 11,913 | 4/8/2025 |
| 9.3.0 | 916 | 3/11/2025 |
| 9.2.0 | 103,585 | 2/11/2025 |
| 9.1.0 | 21,100 | 1/14/2025 |
| 9.0.0 | 6,089 | 11/12/2024 |
| 8.10.0 | 50,432 | 10/8/2024 |