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 writes each record to TestContext.Current.Output as it is logged. The caller owns both: dispose the factory when the test completes.

[SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "The providers are handed to LoggerFactory.Create, which takes ownership and disposes them when the returned factory is disposed by the caller; disposing them here would tear down the live factory.")]
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.