Wolfgang.Extensions.Logging.InMemoryLogger
0.1.3
Prefix Reserved
dotnet add package Wolfgang.Extensions.Logging.InMemoryLogger --version 0.1.3
NuGet\Install-Package Wolfgang.Extensions.Logging.InMemoryLogger -Version 0.1.3
<PackageReference Include="Wolfgang.Extensions.Logging.InMemoryLogger" Version="0.1.3" />
<PackageVersion Include="Wolfgang.Extensions.Logging.InMemoryLogger" Version="0.1.3" />
<PackageReference Include="Wolfgang.Extensions.Logging.InMemoryLogger" />
paket add Wolfgang.Extensions.Logging.InMemoryLogger --version 0.1.3
#r "nuget: Wolfgang.Extensions.Logging.InMemoryLogger, 0.1.3"
#:package Wolfgang.Extensions.Logging.InMemoryLogger@0.1.3
#addin nuget:?package=Wolfgang.Extensions.Logging.InMemoryLogger&version=0.1.3
#tool nuget:?package=Wolfgang.Extensions.Logging.InMemoryLogger&version=0.1.3
Wolfgang.Extensions.Logging.InMemoryLogger
An implementation of ILogger and ILogger<T> from Microsoft.Extensions.Logging that writes log entries to an in-memory collection. Designed for unit and integration tests where you need to assert against logged messages.
📦 Installation
dotnet add package Wolfgang.Extensions.Logging.InMemoryLogger
NuGet Package: Wolfgang.Extensions.Logging.InMemoryLogger
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
📚 Documentation
- GitHub Repository: https://github.com/Chris-Wolfgang/In-memory-Logger
- API Documentation: https://Chris-Wolfgang.github.io/In-memory-Logger/
- CHANGELOG: CHANGELOG.md
- Contributing Guide: CONTRIBUTING.md
- DocFX Version Picker Troubleshooting: docs/DOCFX-VERSION-PICKER.md
✨ Features
- Thread-safe in-memory log entry storage.
- Configurable minimum log level (passed to the constructor; defaults to
LogLevel.Trace). - Configurable initial capacity (defaults to
16). - Supports all .NET log levels (
TracethroughCritical). - Captures scope state via
BeginScopefor assertion in tests. - Returns log entries as
IReadOnlyList<LogEntry<object>>for easy LINQ + assertion patterns. - Ships both a non-generic
InMemoryLogger(constructed with a category string) and a genericInMemoryLogger<T>(category derived fromtypeof(T)), matching the standardILogger/ILogger<T>shape.
🚀 Quick Start
using Microsoft.Extensions.Logging;
using Wolfgang.Extensions.Logging.InMemoryLogger;
// Generic form — category is "MyApp.MyService"
var logger = new InMemoryLogger<MyService>(LogLevel.Information);
// Use the logger in code under test
var service = new MyService(logger);
service.DoWork();
// Assert against captured log entries
Assert.Single(logger.LogEntries);
Assert.Equal(LogLevel.Information, logger.LogEntries[0].LogLevel);
The non-generic form takes a category string directly:
var logger = new InMemoryLogger("MyCategory", LogLevel.Warning, capacity: 32);
🎯 Target Frameworks
| TFM | Status |
|---|---|
net462 |
✅ |
netstandard2.0 |
✅ |
netstandard2.1 |
✅ |
net8.0 |
✅ |
net10.0 |
✅ |
🔍 Code Quality & Static Analysis
This project is held to the canonical analyzer set used across all Chris-Wolfgang .NET libraries. Analyzers run on every build and are treated as errors in Release.
Analyzers in Use
- Microsoft.CodeAnalysis.NetAnalyzers — built-in .NET analyzers (correctness and performance)
- Roslynator.Analyzers — refactoring and code quality
- AsyncFixer — async/await best practices
- Microsoft.VisualStudio.Threading.Analyzers — thread safety
- Microsoft.CodeAnalysis.BannedApiAnalyzers — enforces the
BannedSymbols.txtpolicy - Meziantou.Analyzer — broad code-quality rules
- SonarAnalyzer.CSharp — industry-standard analysis
- Microsoft.CodeAnalysis.PublicApiAnalyzers — public-API surface tracking via
PublicAPI.Shipped.txt/PublicAPI.Unshipped.txt
Banned-API policy
BannedSymbols.txt is the canonical fleet baseline. Banned categories include blocking sync-over-async (Task.Result, Task.Wait()), Thread.Sleep, synchronous file I/O, and several legacy / deprecated APIs.
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for:
- Code quality standards
- Build and test instructions
- Pull request guidelines
- Analyzer configuration details
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
-
.NETStandard 2.0
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
-
.NETStandard 2.1
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
-
net10.0
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
-
net8.0
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.