RzR.Web.Middleware.TraceId
2.0.0.8246
dotnet add package RzR.Web.Middleware.TraceId --version 2.0.0.8246
NuGet\Install-Package RzR.Web.Middleware.TraceId -Version 2.0.0.8246
<PackageReference Include="RzR.Web.Middleware.TraceId" Version="2.0.0.8246" />
<PackageVersion Include="RzR.Web.Middleware.TraceId" Version="2.0.0.8246" />
<PackageReference Include="RzR.Web.Middleware.TraceId" />
paket add RzR.Web.Middleware.TraceId --version 2.0.0.8246
#r "nuget: RzR.Web.Middleware.TraceId, 2.0.0.8246"
#:package RzR.Web.Middleware.TraceId@2.0.0.8246
#addin nuget:?package=RzR.Web.Middleware.TraceId&version=2.0.0.8246
#tool nuget:?package=RzR.Web.Middleware.TraceId&version=2.0.0.8246
RzR.Web.Middleware.TraceId is an ASP.NET Core middleware that replaces the default request trace identifier with a custom value you define. On every incoming HTTP request the middleware overwrites HttpContext.TraceIdentifier with the generated identifier and writes that same value to the X-Trace-Id response header, making it straightforward to correlate log entries with specific requests.
The library has no mandatory external dependencies beyond the standard ASP.NET Core abstractions. Once installed it can be wired into the pipeline with a single line of code, and it offers a range of options for teams that need more control over the format or propagation of trace identifiers.
Key features
- Generates trace identifiers as plain GUIDs, formatted GUIDs, or GUIDs combined with a UTC timestamp.
- Lets you attach a prefix, suffix, and separator to every generated identifier.
- Supports W3C Trace Context propagation by reading and writing the
traceparentheader. - Can preserve a trace identifier arriving on an inbound header such as
X-Request-IdorX-Correlation-Id, which is useful when chaining requests across microservices. - Writes the trace identifier to one or more response headers simultaneously.
- Optionally opens a structured-logging scope so that every log entry produced during the request automatically carries the trace identifier.
- Optionally logs the request path and body (up to a configurable size limit) together with the trace identifier.
- Allows synchronous or asynchronous callbacks to run after the downstream pipeline completes, with access to the fully populated
HttpContext. - Exposes an
ITraceIdAccessorabstraction that can be injected into any service to read the current trace identifier without depending directly onIHttpContextAccessor. - Supports configuration through
appsettings.jsonwith hot-reload viaIOptionsMonitor, so option changes take effect without restarting the application.
Installation
Install the package from NuGet:
Install-Package RzR.Web.Middleware.TraceId
To install a specific version:
Install-Package RzR.Web.Middleware.TraceId -Version x.x.x.x
Quick start
The minimal setup adds the middleware to the request pipeline and generates a new GUID as the trace identifier for every request:
// Program.cs or Startup.cs
app.UseUniqTraceIdMiddleware();
For a more complete setup that binds options from configuration and registers the ITraceIdAccessor service:
// Service registration
builder.Services.AddUniqTraceId(builder.Configuration.GetSection("TraceId"));
// Middleware pipeline
app.UseUniqTraceIdMiddleware();
A minimal appsettings.json section looks like this:
{
"TraceId": {
"TraceType": "Guid",
"ResponseHeaderName": "X-Trace-Id"
}
}
Full configuration reference and additional usage patterns are covered in the documentation below.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.1.32)
- Microsoft.Extensions.Logging.Abstractions (>= 3.1.32)
- Microsoft.Extensions.Options (>= 3.1.32)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 3.1.32)
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 |
|---|---|---|
| 2.0.0.8246 | 106 | 5/6/2026 |