DMNSN.AspNetCore.Middlewares.RqRsLogging
8.0.3
dotnet add package DMNSN.AspNetCore.Middlewares.RqRsLogging --version 8.0.3
NuGet\Install-Package DMNSN.AspNetCore.Middlewares.RqRsLogging -Version 8.0.3
<PackageReference Include="DMNSN.AspNetCore.Middlewares.RqRsLogging" Version="8.0.3" />
paket add DMNSN.AspNetCore.Middlewares.RqRsLogging --version 8.0.3
#r "nuget: DMNSN.AspNetCore.Middlewares.RqRsLogging, 8.0.3"
// Install DMNSN.AspNetCore.Middlewares.RqRsLogging as a Cake Addin #addin nuget:?package=DMNSN.AspNetCore.Middlewares.RqRsLogging&version=8.0.3 // Install DMNSN.AspNetCore.Middlewares.RqRsLogging as a Cake Tool #tool nuget:?package=DMNSN.AspNetCore.Middlewares.RqRsLogging&version=8.0.3
Request and Response Logging Middleware
This repository contains middleware for logging HTTP requests and responses in an ASP.NET Core application. The middleware provides detailed logging of request and response data, including headers, body, and performance metrics.
Installation
To install the middleware, add the following NuGet package to your project:
dotnet add package DMNSN.AspNetCore.Middlewares.RqRsLogging
Usage
To use the middleware, add it to the IApplicationBuilder
in the Startup.cs
file:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseRqRsLoggingMiddleware();
// or
app.UseRqRsSingleLoggingMiddleware();
// Other middlewares
}
You can also configure the middleware using an IConfiguration
instance:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IConfiguration configuration)
{
app.UseRqRsLoggingMiddleware(configuration);
// or
app.UseRqRsSingleLoggingMiddleware(configuration);
// Other middlewares
}
Alternatively, you can pass custom options:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
var options = new RqRsLoggingMiddlewareOptions {
CorrelationKey = "X-Custom-Correlation-ID",
LogRequest = true,
LogResponse = true,
MaxFieldLength = 200,
MaxRequestSizeToLog = 2048,
MaxQueryString = 200
};
app.UseRqRsLoggingMiddleware(options);
// or
app.UseRqRsSingleLoggingMiddleware(options);
// Other middlewares
}
Configuration
The middleware can be configured using the RqRsLoggingMiddlewareOptions
class. The following options are available:
CorrelationKey
: The key used to retrieve the correlation ID from the request headers.LogRequest
: Whether to log the request data.LogResponse
: Whether to log the response data.MaxFieldLength
: The maximum length of a field before it is truncated.MaxRequestSizeToLog
: The maximum size of the request body to log.MaxQueryString
: The maximum length of the query string to log.
License
This project is licensed under the MIT License. See the LICENSE file for more information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- DMNSN.Helpers.Minifier (>= 8.0.2)
- Microsoft.Extensions.Logging (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release. Starting base version with version of dotnet