Soenneker.HttpClients.LoggingHandler 4.0.266

Prefix Reserved
dotnet add package Soenneker.HttpClients.LoggingHandler --version 4.0.266
                    
NuGet\Install-Package Soenneker.HttpClients.LoggingHandler -Version 4.0.266
                    
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="Soenneker.HttpClients.LoggingHandler" Version="4.0.266" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.HttpClients.LoggingHandler" Version="4.0.266" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.HttpClients.LoggingHandler" />
                    
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 Soenneker.HttpClients.LoggingHandler --version 4.0.266
                    
#r "nuget: Soenneker.HttpClients.LoggingHandler, 4.0.266"
                    
#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 Soenneker.HttpClients.LoggingHandler@4.0.266
                    
#: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=Soenneker.HttpClients.LoggingHandler&version=4.0.266
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.HttpClients.LoggingHandler&version=4.0.266
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.HttpClients.LoggingHandler

A delegating handler for structured HTTP request, response, timing, header, and optional body logs.

Install

dotnet add package Soenneker.HttpClients.LoggingHandler

Configure with IHttpClientFactory

using Microsoft.Extensions.Logging;
using Soenneker.HttpClients.LoggingHandler;

var options = new HttpClientLoggingOptions
{
    LogLevel = LogLevel.Debug,
    LogRequestHeaders = true,
    LogResponseHeaders = true,
    LogRequestBody = false,
    LogResponseBody = false
};

services.AddHttpClient("catalog", client =>
{
    client.BaseAddress = new Uri("https://api.example.com/");
})
.AddHttpMessageHandler(serviceProvider =>
    new HttpClientLoggingHandler(
        serviceProvider.GetRequiredService<ILogger<HttpClientLoggingHandler>>(),
        options));

The handler logs the method, path, status code, and elapsed time. Header logging is enabled by default. Request and response bodies and query strings are disabled by default because they commonly contain credentials or personal data.

Redaction and body limits

The default redaction list covers Authorization, Proxy-Authorization, Cookie, Set-Cookie, X-Api-Key, and Api-Key. Replace or extend RedactedHeaders before constructing the handler for application-specific secrets.

var options = new HttpClientLoggingOptions
{
    LogResponseBody = true,
    MaxBodyLogLength = 8_192,
    RedactedHeaders =
    [
        "Authorization",
        "Cookie",
        "Set-Cookie",
        "X-Api-Key",
        "X-Tenant-Token"
    ]
};

MaxBodyLogLength defaults to 4,096 characters. A negative value or int.MaxValue removes the limit and can buffer arbitrarily large content; use that only with payload sizes you control.

Limited body logging captures a bounded prefix as the transport or caller consumes the content, without eagerly reading or buffering it. The preview is logged when its byte budget fills, consumption completes, or the content is disposed. The complete body remains available downstream, including for non-seekable streams and unknown content lengths. Explicitly unlimited logging buffers and rewinds the complete body.

Set LogQueryString = true only when query parameters are known not to contain secrets. URI query values and body fields are not selectively redacted: when enabled, they are logged as supplied.

Product Compatible and additional computed target framework versions.
.NET 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 (4)

Showing the top 4 NuGet packages that depend on Soenneker.HttpClients.LoggingHandler:

Package Downloads
Soenneker.GitHub.Client.Http

Provides a configured, cached HttpClient for GitHub's REST API.

Soenneker.Cloudflare.HttpClient

An async thread-safe HttpClient singleton for the Cloudflare API

Soenneker.Instantly.ClientUtil

Provides a lazily created Instantly generated client over a reusable authenticated transport

Soenneker.Telnyx.Client

Provide a cached HttpClient with Telnyx REST API authentication.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.266 0 10/15/2026
4.0.265 0 10/14/2026
4.0.264 0 10/14/2026
4.0.263 0 10/14/2026
4.0.261 28 10/14/2026
4.0.255 59 10/13/2026
4.0.254 149 10/12/2026
4.0.252 200 10/12/2026
4.0.251 139 10/12/2026
4.0.250 1,087 10/12/2026
4.0.249 473 10/11/2026
4.0.248 81 10/11/2026
4.0.247 228 10/11/2026
4.0.246 28,578 9/30/2026
4.0.245 6,035 9/29/2026
4.0.244 11,009 9/25/2026
4.0.243 94 9/25/2026
4.0.242 203 9/24/2026
4.0.241 18,340 9/16/2026
4.0.240 141 9/16/2026
Loading failed

Updated NuGet packages