Introduction
Welcome to Wolfgang.Extensions.Logging.InMemoryLogger.
Overview
Wolfgang.Extensions.Logging.InMemoryLogger is a .NET library that provides ILogger and ILogger<T> implementations which capture log entries in an in-memory buffer. It is designed for unit and integration tests where you need to assert that production code logged the messages you expect.
Key Features
- Two logger shapes.
InMemoryLogger(non-generic, category passed as a string) andInMemoryLogger<T>(generic, category derived fromtypeof(T)) — matches the standardMicrosoft.Extensions.LoggingILogger/ILogger<T>pair. - Captured entries.
LogEntriesreturnsIReadOnlyList<LogEntry<object>>fromMicrosoft.Extensions.Logging.Abstractionsso the captured entries plug directly into LINQ and xUnit asserts. - Scope capture.
BeginScoperecords the supplied state object into theScopesproperty so scope-aware code paths can be asserted on. - Configurable. Constructor parameters control the minimum log level (defaults to
Trace) and the initial buffer capacity (defaults to16). - Thread-safe. Concurrent
Logcalls append safely. - Multi-targeted. Ships for
net462,netstandard2.0,netstandard2.1,net8.0, andnet10.0.
Getting Help
If you need help with Wolfgang.Extensions.Logging.InMemoryLogger, please:
- Browse the API Reference
- Read the Getting Started guide
- File an issue at https://github.com/Chris-Wolfgang/In-memory-Logger/issues