Rig.TUnit.Observability.Logging
0.1.0-beta.2
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
<PackageReference Include="Rig.TUnit.Observability.Logging" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Observability.Logging" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Observability.Logging" />
paket add Rig.TUnit.Observability.Logging --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Observability.Logging, 0.1.0-beta.2"
#:package Rig.TUnit.Observability.Logging@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Observability.Logging&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Observability.Logging&version=0.1.0-beta.2&prerelease
Rig.TUnit.Observability.Logging
In-memory
ILogger<T>capture with structured-scope stack, fluentLogAssert, and runtimeAntiPatternDetector(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.LoggingFixtureRig.TUnit.Observability.Logging.Options.LoggingFixtureOptionsRig.TUnit.Observability.Logging.Builder.LoggingRigBuilderRig.TUnit.Observability.Logging.Assertions.LogAssertRig.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 — theMinLevelfiltered the entry out. Checkfx.MinLevelmatches the level you expect.AntiPatternDetectorflags a non-PII property — tune theAntiPatternDetector.IgnorePropertieslist for the false positive.
See docs/troubleshooting.md#logging.
Provider quirks + edge cases
BeginScopestate is captured as an opaque object — the harness deep-clones it viaJsonSerializerso 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.AntiPatternDetectorflags the positional form.
Benchmarks
See LoggingBenchmarks.cs;
baseline in benchmarks/baseline-005.json.
Related docs
- Architecture diagram
- Glossary
- Family base:
Rig.TUnit.Observability - Sibling:
Rig.TUnit.Observability.Logging.Analyzers
License
MIT. See LICENSE.
| 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
- Bogus (>= 35.6.1)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- Rig.TUnit.Observability (>= 0.1.0-beta.2)
- TUnit.Core (>= 1.34.5)
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 |