Table of Contents

Class TestOutputLogCollectorBuilder

Namespace
LogAssertions.TUnit
Assembly
LogAssertions.TUnit.dll

TUnit-specific counterpart to LogCollectorBuilder that, in addition to capturing records into a Microsoft.Extensions.Logging.Testing.FakeLogCollector for assertions, mirrors each record live to the active TUnit test's output writer. Use this when you want the test's logs to appear inline in the per-test report; use the core Create(LogLevel) (no tee) for log-heavy soak tests where buffering every record in the per-test output is undesirable.

public static class TestOutputLogCollectorBuilder
Inheritance
TestOutputLogCollectorBuilder
Inherited Members

Methods

CreateTeed(LogLevel)

Creates a Microsoft.Extensions.Logging.Testing.FakeLogCollector and an ILoggerFactory wired to it, plus a provider that mirrors each record to the test's output as it is logged. The owning test is captured when this runs (on the test's own thread), so a record logged on a background thread is teed rather than dropped. The caller owns both: dispose the factory when the test completes.

public static (ILoggerFactory Factory, FakeLogCollector Collector) CreateTeed(LogLevel minimumLevel = LogLevel.Trace)

Parameters

minimumLevel LogLevel

The minimum level to capture (and tee). Default is Trace (everything).

Returns

(ILoggerFactory Factory, FakeLogCollector Collector)

The wired pair: Factory for creating loggers, Collector for assertions.