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                
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="DMNSN.AspNetCore.Middlewares.RqRsLogging" Version="8.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DMNSN.AspNetCore.Middlewares.RqRsLogging --version 8.0.3                
#r "nuget: DMNSN.AspNetCore.Middlewares.RqRsLogging, 8.0.3"                
#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 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 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. 
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
8.0.3 91 8/2/2024
8.0.2 83 8/2/2024
8.0.1 82 8/2/2024

Initial release. Starting base version with version of dotnet