Class InMemoryLoggerProvider
- Namespace
- Wolfgang.Extensions.Logging.InMemoryLogger
- Assembly
- Wolfgang.Extensions.Logging.InMemoryLogger.dll
An ILoggerProvider that creates InMemoryLogger instances and provides access to all log entries across all loggers.
public sealed class InMemoryLoggerProvider : ILoggerProvider, IDisposable
- Inheritance
-
InMemoryLoggerProvider
- Implements
- Inherited Members
Constructors
InMemoryLoggerProvider(LogLevel)
Initializes a new instance of the InMemoryLoggerProvider class.
public InMemoryLoggerProvider(LogLevel minLogLevel = LogLevel.Trace)
Parameters
minLogLevelLogLevelThe minimum log level for all loggers created by this provider.
Properties
LogEntries
Returns all log entries from all loggers created by this provider. Entries are grouped by logger category; ordering across categories is not guaranteed.
[SuppressMessage("Major Code Smell", "S2365:Properties should not make collection or array copies", Justification = "This is a test-helper property whose entire purpose is to return a snapshot view; the copy semantics are intentional and idiomatic for assertion code.")]
public IReadOnlyList<LogEntry<object>> LogEntries { get; }
Property Value
Remarks
Each access materializes a snapshot of the entries across all loggers; the cost is O(n) in the total entry count. Test code typically reads this once per assertion.
Loggers
Returns all logger instances created by this provider.
[SuppressMessage("Major Code Smell", "S2365:Properties should not make collection or array copies", Justification = "This is a test-helper property whose entire purpose is to return a snapshot view; the copy semantics are intentional and idiomatic for assertion code.")]
public IReadOnlyDictionary<string, InMemoryLogger> Loggers { get; }
Property Value
Remarks
Each access materializes a snapshot copy of the underlying logger map; cost is O(n) in the number of distinct categories logged through this provider.
Methods
CreateLogger(string)
Creates a new InMemoryLogger with the given category name.
public ILogger CreateLogger(string categoryName)
Parameters
categoryNamestringThe category name for messages produced by the logger.
Returns
Exceptions
- ArgumentNullException
Thrown when
categoryNameis null.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()