Pragmatic.Logging 1.0.0-alpha.4

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

Pragmatic.Logging

Feature-rich structured logging for the Pragmatic.Design ecosystem: extends .NET ILogger with privacy-aware redaction, an audit trail, context enrichment, an expression filter DSL, and multiple providers.

Performance: with every library writing into a sink that renders and reads the event, Pragmatic is first of Pragmatic, ZLogger, NLog and Serilog in all seven benchmarked scenarios on the CI runner, the production preset with context enrichment included, and allocates the least in each. Its narrowest leads are Structured and Production, 3% and 2% ahead of ZLogger. A JSON line written from a generated call site is the fastest of the four and allocates nothing; one written from Microsoft's [LoggerMessage] is ahead of Serilog's and NLog's and allocates 144 B. See BENCHMARK-RESULTS.md for the runs, the machines and the reports.

The Problem

Production logging needs structured output, PII redaction, correlation IDs, rate limiting, and multiple targets. Microsoft.Extensions.Logging gives you the ILogger foundation and leaves the rest to you. String interpolation allocates on every call (even when the level is off), secrets leak when someone forgets to sanitize, and context must be threaded by hand.

// Without Pragmatic: allocates always, leaks PII + secrets, no context
logger.LogInformation($"Order {orderId} by {email} via {connectionString}");

The Solution

A fluent PragmaticLoggingBuilder over standard ILogger<T> (no proprietary abstraction) configures every concern in one place: providers, presets, privacy, performance, context enrichment.

builder.Services.AddPragmaticLogging(logging => logging
    .UseProductionPreset()                         // background processing, rate limiting, correlation IDs
    .AddConsole()
    .AddFile("logs/app-{Date}.log")                // rolling file with retention
    .EnableDataRedaction(r => r.SensitivePropertyNames = ["password", "email", "apiKey"]));

In a Pragmatic host the same builder is app.UseLogging(logging => …). There is one builder, Pragmatic.Logging.Extensions.PragmaticLoggingBuilder; ILoggingBuilder.AddPragmaticLogging() no longer exists.

On hot paths, write [LoggerMessage] methods: with Pragmatic.SourceGenerator referenced they are Pragmatic call sites, whose state writes itself as UTF-8 and masks a [PersonalData] argument at the call site. Structured properties, automatic PII/secret redaction, an audit trail, and context enrichment come built in.

Installation

dotnet add package Pragmatic.Logging

Status

Functional within 1.0.0-alpha: the builder, the providers (console, rolling file, JSON, NDJSON, memory, debug, null, Windows Event Log), presets, redaction, the audit trail, rate limiting, and context enrichment. See the roadmap.

Documentation

Guide What you'll learn
Concepts The builder model, presets, zero-allocation infrastructure
Getting Started Configure providers and write your first structured logs
Providers The eight providers, choosing one, writing your own
Context Enrichment Correlation IDs, ambient context, scopes
Privacy & Security PII/secret redaction, audit trail
Log call sites [LoggerMessage] with the Pragmatic generator: UTF-8 state, masking at the call site
Performance [LoggerMessage], the zero-allocation formatter, rate limiting
Common Mistakes The most frequent logging pitfalls
Troubleshooting Problem/solution guide

Requirements

  • .NET 10.0+

License

Part of the Pragmatic.Design ecosystem. See Licensing. Pragmatic.Logging is MIT-licensed.

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
1.0.0-alpha.6 93 11/21/2026
1.0.0-alpha.5 56 11/21/2026
1.0.0-alpha.4 116 11/16/2026
1.0.0-alpha.3 381 10/17/2026
1.0.0-alpha.2 124 10/12/2026
1.0.0-alpha.1 341 10/3/2026