Pragmatic.Logging
1.0.0-alpha.4
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
<PackageReference Include="Pragmatic.Logging" Version="1.0.0-alpha.4" />
<PackageVersion Include="Pragmatic.Logging" Version="1.0.0-alpha.4" />
<PackageReference Include="Pragmatic.Logging" />
paket add Pragmatic.Logging --version 1.0.0-alpha.4
#r "nuget: Pragmatic.Logging, 1.0.0-alpha.4"
#:package Pragmatic.Logging@1.0.0-alpha.4
#addin nuget:?package=Pragmatic.Logging&version=1.0.0-alpha.4&prerelease
#tool nuget:?package=Pragmatic.Logging&version=1.0.0-alpha.4&prerelease
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 | Versions 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. |
-
net10.0
- OpenTelemetry (>= 1.15.3)
- Pragmatic.Abstractions (>= 1.0.0-alpha.4)
- Pragmatic.Redaction (>= 1.0.0-alpha.4)
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 |