Rig.TUnit.Observability.Logging 0.1.0-beta.2

This is a prerelease version of Rig.TUnit.Observability.Logging.
dotnet add package Rig.TUnit.Observability.Logging --version 0.1.0-beta.2
                    
NuGet\Install-Package Rig.TUnit.Observability.Logging -Version 0.1.0-beta.2
                    
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="Rig.TUnit.Observability.Logging" Version="0.1.0-beta.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rig.TUnit.Observability.Logging" Version="0.1.0-beta.2" />
                    
Directory.Packages.props
<PackageReference Include="Rig.TUnit.Observability.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 Rig.TUnit.Observability.Logging --version 0.1.0-beta.2
                    
#r "nuget: Rig.TUnit.Observability.Logging, 0.1.0-beta.2"
                    
#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 Rig.TUnit.Observability.Logging@0.1.0-beta.2
                    
#: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=Rig.TUnit.Observability.Logging&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Rig.TUnit.Observability.Logging&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Tool

Rig.TUnit.Observability.Logging

In-memory ILogger<T> capture with structured-scope stack, fluent LogAssert, and runtime AntiPatternDetector (PII + interpolated templates).

What this package is

A logging integration-test fixture. LoggingFixture provides a CreateLogger(category) factory backed by an in-memory ILoggerProvider that captures every log entry plus the full BeginScope stack. LogAssert gives fluent assertions over the captured entries: LogAssert.Logged(fx, LogLevel.Information).WithProperty("OrderId", 42).Once(). AntiPatternDetector runs at assertion time and catches two of the most common logging foot-guns: PII in structured properties and string-interpolated log templates.

When to use it

  • Asserting log messages emitted under specific conditions.
  • Regression-testing log shape after a refactor.
  • Catching interpolated templates ($"...") before they land in prod.
  • Not for: volumetric load testing — the in-memory capture is unbounded and will OOM on millions of entries.

Prerequisites

  • .NET 10 SDK
  • Microsoft.Extensions.Logging (transitive)

Quick start

using Microsoft.Extensions.Logging;
using Rig.TUnit.Observability.Logging.Fixtures;

await using var fx = new LoggingFixture();
await fx.InitializeAsync();

fx.CreateLogger("Orders").LogInformation("Processing {OrderId}", 42);

Options

Property Type Default Description
MinLevel LogLevel Trace Below this, entries are dropped
CaptureScopes bool true Record BeginScope stack
ThrowOnAntiPattern bool false If true, the fixture fails fast on detection

Fixture + helper APIs

  • Rig.TUnit.Observability.Logging.Fixtures.LoggingFixture
  • Rig.TUnit.Observability.Logging.Options.LoggingFixtureOptions
  • Rig.TUnit.Observability.Logging.Builder.LoggingRigBuilder
  • Rig.TUnit.Observability.Logging.Assertions.LogAssert
  • Rig.TUnit.Observability.Logging.Helpers.AntiPatternDetector

Per-test isolation

Each LoggingFixture owns its entry buffer. No shared state. Safe under full parallelism.

Parallelism + performance

  • Fixture construction: ~1 ms.
  • Per-log overhead: ~5 µs (capture + scope clone).
  • Safe under full parallelism.

Troubleshooting

  • LogAssert.Logged(…).Once() fails with 0 — the MinLevel filtered the entry out. Check fx.MinLevel matches the level you expect.
  • AntiPatternDetector flags a non-PII property — tune the AntiPatternDetector.IgnoreProperties list for the false positive.

See docs/troubleshooting.md#logging.

Provider quirks + edge cases

  • BeginScope state is captured as an opaque object — the harness deep-clones it via JsonSerializer so later mutations do not corrupt the captured scope.
  • Structured properties under {Name} placeholders are what gets captured; positional {0}-style logs capture only the formatted string. AntiPatternDetector flags the positional form.

Benchmarks

See LoggingBenchmarks.cs; baseline in benchmarks/baseline-005.json.

License

MIT. See LICENSE.

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 (2)

Showing the top 2 NuGet packages that depend on Rig.TUnit.Observability.Logging:

Package Downloads
Rig.TUnit.All

Meta-package containing every Rig.TUnit.* package. DISCOURAGED — prefer per-feature or per-stack meta-packages (Rig.TUnit, Rig.TUnit.Microservices).

Rig.TUnit.Microservices

Meta-package: Core + Mediator + Grpc + Outbox + Tracing + Jwt + Seq — the opinionated microservice testing kit.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-beta.2 46 4/27/2026
0.0.0-alpha.0.14 47 4/26/2026