Ogu.Extensions.Logging.HttpClient 1.0.3

dotnet add package Ogu.Extensions.Logging.HttpClient --version 1.0.3                
NuGet\Install-Package Ogu.Extensions.Logging.HttpClient -Version 1.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="Ogu.Extensions.Logging.HttpClient" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ogu.Extensions.Logging.HttpClient --version 1.0.3                
#r "nuget: Ogu.Extensions.Logging.HttpClient, 1.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 Ogu.Extensions.Logging.HttpClient as a Cake Addin
#addin nuget:?package=Ogu.Extensions.Logging.HttpClient&version=1.0.3

// Install Ogu.Extensions.Logging.HttpClient as a Cake Tool
#tool nuget:?package=Ogu.Extensions.Logging.HttpClient&version=1.0.3                

Ogu.Extensions.Logging.HttpClient enhances logging capabilities for HttpClient by providing a structural logging mechanism

Usage

Registration:

services.AddHttpClientLogging(opts =>
{
    opts.IncludeQueryInRequestPath = false;
    opts.IncludeRequestBody = false;
    opts.IncludeRequestHeaders = false;
    opts.IncludeResponseBody = false;
    opts.IncludeResponseHeaders = false;
});

output

[2024-05-23T14:41:01.8868645Z-Dev-inf]: Ogu.Extensions.Logging.HttpClient.Exchange.Default.LogicalHandler
                                        GET https://localhost:7215/api/samples responded 200 (OK) in 803.5644ms

Enrich CorrelationId (Extra)

If Ogu.Extensions.Logging.HttpMiddleware in use ( Web-based application I recommend )

services.AddHttpClientLogging(opts =>
{
    opts.EnrichLoggingRequest = (loggingContext, message, services) =>
    {
        message.Headers.AddCorrelationIdHeaderIfMissingWithHttpContext(loggingContext, services);
    };
});

Prefer below Unless, web-based application:

services.AddHttpClientLogging(opts =>
{
    opts.EnrichLoggingRequest = (loggingContext, message, _) =>
    {
        message.Headers.AddCorrelationIdHeaderIfMissing(loggingContext);
    };
});
[2024-05-27T23:28:18.4737851Z-Dev-inf]: Ogu.Extensions.Logging.HttpClient.Exchange.Default.LogicalHandler
[35b23e4f-fa9c-4173-b130-6ffe764f4a85]  GET https://localhost:7215/api/samples responded 200 (OK) in 48.9729ms

Sample Application

A sample application demonstrating the usage of Ogu.Extensions.Logging.HttpClient & Ogu.Extensions.Logging.HttpMiddleware be found here.

Links:

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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 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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  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. 
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
1.0.3 91 5/28/2024
1.0.2 92 5/27/2024
1.0.1 91 5/27/2024
1.0.0 100 5/23/2024