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
Returns
- (ILoggerFactory Factory, FakeLogCollector Collector)
The wired pair:
Factoryfor creating loggers,Collectorfor assertions.