Quilt4Net.Toolkit.Api 0.6.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Quilt4Net.Toolkit.Api --version 0.6.1
                    
NuGet\Install-Package Quilt4Net.Toolkit.Api -Version 0.6.1
                    
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="Quilt4Net.Toolkit.Api" Version="0.6.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Quilt4Net.Toolkit.Api" Version="0.6.1" />
                    
Directory.Packages.props
<PackageReference Include="Quilt4Net.Toolkit.Api" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Quilt4Net.Toolkit.Api --version 0.6.1
                    
#r "nuget: Quilt4Net.Toolkit.Api, 0.6.1"
                    
#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.
#:package Quilt4Net.Toolkit.Api@0.6.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Quilt4Net.Toolkit.Api&version=0.6.1
                    
Install as a Cake Addin
#tool nuget:?package=Quilt4Net.Toolkit.Api&version=0.6.1
                    
Install as a Cake Tool

Quilt4Net.Toolkit.Api

GitHub repo

HTTP request/response logging and correlation tracking middleware for .NET Web Applications.

Captures method, path, headers, query parameters, request/response bodies, client IP, and execution time. Logs to Application Insights and/or standard ILogger.

Get started

Install the NuGet package Quilt4Net.Toolkit.Api and register the service in Program.cs.

var builder = WebApplication.CreateBuilder(args);

builder.AddQuilt4NetApiLogging();

var app = builder.Build();

app.UseQuilt4NetApiLogging();

app.Run();

By default, all requests to paths starting with /Api are logged.

Correlation ID

When UseCorrelationId is enabled (default), the middleware reads the X-Correlation-ID header from incoming requests. If no header is present, a new GUID is generated. The correlation ID is stored in HttpContext.Items and returned in the response header, enabling distributed tracing across services.

Logging mode

Control where logs are sent using HttpRequestLogMode.

builder.AddQuilt4NetApiLogging(o =>
{
    o.LogHttpRequest = HttpRequestLogMode.ApplicationInsights | HttpRequestLogMode.Logger;
});
Value Description
None No logging.
ApplicationInsights Append request/response data to Application Insights request telemetry.
Logger Log via the standard ILogger pipeline.

Values can be combined with | to log to multiple destinations.

Path filtering

By default, only paths matching ^/Api (case-insensitive) are logged. Override with regex patterns.

builder.AddQuilt4NetApiLogging(o =>
{
    o.IncludePaths = [".*"]; // Log all paths
});

Per-endpoint control

Use [Logging] and [LoggingStream] attributes to override logging behavior on individual endpoints.

[Logging(RequestBody = true, ResponseBody = false)]
public async Task<IActionResult> StreamData() { ... }

[Logging(Enabled = false)]
public IActionResult InternalEndpoint() { ... }

[LoggingStream] // Shorthand for ResponseBody = false
public async Task<IActionResult> StreamEvents() { ... }

The [Logging] attribute can be applied to methods or classes.

Property Default Description
Enabled true Enable or disable all logging for the endpoint.
RequestBody true Log the request body.
ResponseBody true Log the response body. Set to false for streaming endpoints.

Interceptor

Use an interceptor to modify or filter logged data before it is written. This is useful for removing sensitive information such as passwords or API keys.

builder.AddQuilt4NetApiLogging(o =>
{
    o.Interceptor = async (request, response, properties, serviceProvider) =>
    {
        // Remove sensitive headers
        request.Headers.Remove("Authorization");
        return (request, response, properties);
    };
});

Configuration

All options can be set via code or appsettings.json. Code takes priority over appsettings.json, which takes priority over defaults.

Code configuration

builder.AddQuilt4NetApiLogging(o =>
{
    o.LogHttpRequest = HttpRequestLogMode.ApplicationInsights;
    o.UseCorrelationId = true;
    o.MaxBodySize = 5_000_000;
    o.IncludePaths = ["^/Api", "^/webhook"];
    o.LogRequestBodyByDefault = true;
    o.LogResponseBodyByDefault = false;
});

appsettings.json

{
  "Quilt4Net": {
    "ApiLogging": {
      "LogHttpRequest": 1,
      "UseCorrelationId": true,
      "MonitorName": "Quilt4Net",
      "MaxBodySize": 1000000,
      "IncludePaths": ["^/Api"],
      "LogRequestBodyByDefault": true,
      "LogResponseBodyByDefault": false
    }
  }
}

Configuration path: Quilt4Net:ApiLogging

LoggingOptions

Property Default Description
LogHttpRequest ApplicationInsights Logging destination. Combine with \| for multiple.
UseCorrelationId true Enable X-Correlation-ID header tracking.
MonitorName "Quilt4Net" Monitor name for tracking log items. Set to empty to omit.
MaxBodySize 1 MB Maximum body size to log. Set to 0 to disable body logging.
IncludePaths ["^/Api"] Regex patterns (case-insensitive) for paths to include.
LogRequestBodyByDefault true Log request body by default. Override per endpoint with [Logging].
LogResponseBodyByDefault false Log response body by default. Override per endpoint with [Logging].
Interceptor null Callback to modify or filter logged data before writing.

Logged data

Request

Field Description
Method HTTP method (GET, POST, etc.).
Path Request path.
Headers Request headers (cookies are automatically filtered).
Query Query string parameters.
Body Request body (respects MaxBodySize limit).
ClientIp Client IP address.

Response

Field Description
StatusCode HTTP status code.
Headers Response headers.
Body Response body (respects MaxBodySize limit).
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.  net9.0 is compatible.  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 is compatible.  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. 
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
0.6.3 83 3/8/2026
0.6.2 78 3/8/2026
0.6.1 84 3/8/2026
0.5.4 308 2/7/2026
0.5.2 128 1/31/2026
0.4.7 136 1/8/2026
0.4.4 109 1/6/2026
0.4.2 108 1/6/2026
0.3.9 472 12/8/2025
0.3.7 517 12/1/2025
0.3.5 370 11/30/2025
0.3.2 697 11/19/2025
0.2.8 359 11/12/2025
0.2.6 301 11/11/2025
0.1.34 226 11/3/2025
0.1.32 227 10/27/2025
0.1.30 293 9/14/2025
0.1.28 242 8/20/2025
0.1.26 217 8/18/2025
Loading failed