Pacem.Extensions.Logging.Http 0.10.18-pascal

This is a prerelease version of Pacem.Extensions.Logging.Http.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Pacem.Extensions.Logging.Http --version 0.10.18-pascal
                    
NuGet\Install-Package Pacem.Extensions.Logging.Http -Version 0.10.18-pascal
                    
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="Pacem.Extensions.Logging.Http" Version="0.10.18-pascal" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pacem.Extensions.Logging.Http" Version="0.10.18-pascal" />
                    
Directory.Packages.props
<PackageReference Include="Pacem.Extensions.Logging.Http" />
                    
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 Pacem.Extensions.Logging.Http --version 0.10.18-pascal
                    
#r "nuget: Pacem.Extensions.Logging.Http, 0.10.18-pascal"
                    
#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 Pacem.Extensions.Logging.Http@0.10.18-pascal
                    
#: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=Pacem.Extensions.Logging.Http&version=0.10.18-pascal&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Pacem.Extensions.Logging.Http&version=0.10.18-pascal&prerelease
                    
Install as a Cake Tool

HTTP Logging Extensions

⚗️ ==Experimental==

⚠️ Experimental libs are discouraged to use in production.

About

Pacem.Extensions.Logging.Http provides extensions to ship your logs to an HTTP endpoint (a webhook, a log-ingestion API, a collector, ...).

Delivery goes through an HttpClient (from IHttpClientFactory) and is performed by a background consumer, one entry at a time, so logging calls never block on the network.

⚠️ The IHttpClientFactory pipeline logs its own requests under the System.Net.Http.* categories. Left unfiltered those entries feed straight back into this sink and amplify without bound — scope the sink to the categories you actually care about (builder.AddFilter(...) or the filter argument) or silence System.Net.Http.

⚠️ The sink does not own its HttpClient. Point clientFactory at a client you configured (AddHttpClient), or emit absolute URIs and headers from your converter/executor. The no-clientFactory fallback is the default IHttpClientFactory client, which is unconfigured unless you set it up app-wide with ConfigureHttpClientDefaults.

The following paragraphs exemplify the library utilization given common use cases.

How to

Add the logger to the logging builder (e.g. ILoggingBuilder). There are two ways to describe a delivery, and two ways to supply the HttpClient.

1. Converter mode — build the request, the sink sends it

Provide a HttpRequestLogPayload -> HttpRequestMessage converter.

// Program.cs
builder.Logging.AddPacemHttpLogging(
    // log line -> request
    log => new HttpRequestMessage(HttpMethod.Post, "/ingest")
    {
        Content = JsonContent.Create(new
        {
            timestamp = log.Timestamp,
            source = log.Name,
            level = log.LogLevel.ToString(),
            message = log.Message,
            error = log.Exception?.ToString(),
            data = log.Data
        })
    });

2. Executor mode — you own the send

Provide a (HttpClient, HttpRequestLogPayload) -> Task. Handy when you call an SDK, batch differently, or need the response.

builder.Logging.AddPacemHttpLogging(
    async (client, log) =>
    {
        using var response = await client.PostAsJsonAsync("/ingest", new
        {
            source = log.Name,
            level = log.LogLevel.ToString(),
            message = log.Message
        });
        response.EnsureSuccessStatusCode();
    });

Supplying the HttpClient

Both modes take the same two optional arguments after the delivery delegate:

Argument Type Purpose
clientFactory Func<IHttpClientFactory, HttpRequestLogPayload, HttpClient> Picks or builds the client per entry.
filter Func<HttpRequestLogPayload, bool> Evaluated on the payload before it is queued; return false to drop the entry.

The recommended way to give the sink a base address, default headers, a primary handler or Polly policies is to configure your own client and select it with clientFactory:

builder.Services.AddHttpClient("my-logs", c =>
{
    c.BaseAddress = new Uri("https://logs.example.com");
    c.DefaultRequestHeaders.Add("X-Api-Key", "…");
});

builder.Logging.AddPacemHttpLogging(
    log => new HttpRequestMessage(HttpMethod.Post, "/ingest") { /* … */ },
    clientFactory: (factory, log) => factory.CreateClient("my-logs"),
    // don't ship our own transport noise back over HTTP
    filter: log => !log.Name.StartsWith("System.Net.Http"));

Without clientFactory the sink uses the default IHttpClientFactory client, so the converter/executor must produce absolute URIs (and set any headers on the request itself), unless you configure the default client app-wide:

builder.Services.ConfigureHttpClientDefaults(b =>
    b.ConfigureHttpClient(c => c.BaseAddress = new Uri("https://logs.example.com")));

3. Full control

builder.Logging.AddPacemHttpLogging(options =>
{
    options.FormatHttpRequestMessage = log => /* ... */;   // or options.SendHttpLogAsync
    options.CreateHttpClient = (factory, log) => factory.CreateClient("my-configured-client");
    options.Filter = log => log.LogLevel >= LogLevel.Warning;
});
Option Purpose
FormatHttpRequestMessage The converter.
SendHttpLogAsync The executor.
CreateHttpClient Per-entry client selection from the IHttpClientFactory.
Filter Content predicate, evaluated before the payload is queued.

ℹ️ Set at least one of FormatHttpRequestMessage / SendHttpLogAsync — otherwise the sink throws on the first write.

Plans for version next

Optional client-side batching and a retry / dead-letter policy.

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

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.10.18-selberg 32 10/1/2026
0.10.18-riemann 84 9/26/2026
0.10.18-pascal 90 9/21/2026
0.10.17 94 9/18/2026
0.10.17-foucault 87 9/18/2026
0.10.16 87 9/16/2026
0.10.16-hamilton 80 9/14/2026
0.10.16-gauss 84 9/14/2026
0.10.16-faraday 95 9/9/2026
0.10.15 95 9/7/2026
0.10.15-euler 86 9/7/2026
0.10.14 102 9/6/2026
0.10.14-dedekind 106 9/6/2026
0.10.14-cauchy 101 9/5/2026
0.10.14-boltzmann 93 9/5/2026
0.10.13 104 9/3/2026
0.10.13-abel 92 9/3/2026
0.10.12 89 9/3/2026
0.10.11 99 8/26/2026
0.10.10 126 7/28/2026
Loading failed