Table of Contents

Namespace LogAssertions

Classes

FakeLogCollectorInspectionExtensions

Non-asserting inspection helpers on Microsoft.Extensions.Logging.Testing.FakeLogCollector. Use these when a test needs to read the captured records as data: for downstream calculations, debugging output, or cross-checking: rather than to assert. None of these methods throw on mismatch.

LogAssertionRendering

Shared helpers for rendering captured log records into human-readable text. Used both by the assertion classes (failure-message snapshot rendering) and by the FakeLogCollectorInspectionExtensions.DumpTo extension.

LogCollectorBuilder

Convenience factory that constructs a Microsoft.Extensions.Logging.Testing.FakeLogCollector together with an ILoggerFactory that writes into it. Replaces the 3-4 lines of boilerplate every test would otherwise need.

LogDefinition

The captured shape of one log call: event ID, level, message template, formatted placeholder values, and exception. Created via Capture(Action<ILogger>), which invokes a logging delegate once against a private probe logger and records what it emitted, so a [LoggerMessage] source-generated definition (or any other log call) becomes a reusable, string-free assertion value. Store instances in static readonly fields and match them on the assertion chain via Matching(definition), or build filters directly with Matching(LogDefinition).

LogFilter

Static factory for composable ILogRecordFilter instances. The fluent chain on HasLogged()/HasNotLogged()/HasLoggedSequence() creates filters internally; this class exposes the same primitives for users who want to build reusable filter objects, share them across tests, or compose them via All(params ILogRecordFilter[]) / Any(params ILogRecordFilter[]) / Not(ILogRecordFilter).

Interfaces

ILogRecordFilter

A composable filter over Microsoft.Extensions.Logging.Testing.FakeLogRecord. Built-in filter methods on the assertion fluent chain (AtLevel, Containing, etc.) each create one of these internally; WithFilter(ILogRecordFilter) on the chain accepts arbitrary user implementations, and the LogFilter static factory composes them via All, Any, and Not.

Enums

DumpVerbosity

Verbosity level for DumpTo(TextWriter, DumpVerbosity) and the TUnit-side DumpToTestOutput(DumpVerbosity) overload. Controls how much detail is rendered per record: just the headline (Compact), the standard one-line-each detail (Default), or the full exception stack trace alongside the rest (Verbose).