Class RecordingLogger<TCategoryName>
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
TCategoryNameThe type whose name is used as the logger category.
- Inheritance
-
objectRecordingLogger<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
stateTState
Returns
- IDisposable
Type Parameters
TState
IsEnabled(LogLevel)
public bool IsEnabled(LogLevel logLevel)
Parameters
logLevelLogLevel
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
logLevelLogLeveleventIdEventIdstateTStateexceptionExceptionformatterFunc<TState, Exception, string>
Type Parameters
TState