Table of Contents

Class RecordingLogger<TCategoryName>

Namespace
CMS.Tests
Assembly
CMS.Tests.dll

Implementation of an Microsoft.Extensions.Logging.ILogger<TCategoryName> interface that records the level and event ID of every logged message, so tests can assert on what was logged.

public sealed class RecordingLogger<TCategoryName>

Type Parameters

TCategoryName

The type whose name is used as the logger category.

Inheritance
object
RecordingLogger<TCategoryName>
Extension Methods

Constructors

RecordingLogger()

public RecordingLogger()

Properties

Records

The level and event ID of every message logged so far, in the order they were logged.

public List<(LogLevel Level, EventId EventId)> Records { get; }

Property Value

List<(LogLevel Level, EventId EventId)>

Methods

BeginScope<TState>(TState)

public IDisposable BeginScope<TState>(TState state)

Parameters

state TState

Returns

IDisposable

Type Parameters

TState

IsEnabled(LogLevel)

public bool IsEnabled(LogLevel logLevel)

Parameters

logLevel LogLevel

Returns

bool

Log<TState>(LogLevel, EventId, TState, Exception, Func<TState, Exception, string>)

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)

Parameters

logLevel LogLevel
eventId EventId
state TState
exception Exception
formatter Func<TState, Exception, string>

Type Parameters

TState