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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Wolfgang.Extensions.Logging.InMemoryLogger" Version="0.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Wolfgang.Extensions.Logging.InMemoryLogger" Version="0.1.3" />
                    
Directory.Packages.props
<PackageReference Include="Wolfgang.Extensions.Logging.InMemoryLogger" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Wolfgang.Extensions.Logging.InMemoryLogger --version 0.1.3
                    
#r "nuget: Wolfgang.Extensions.Logging.InMemoryLogger, 0.1.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Wolfgang.Extensions.Logging.InMemoryLogger@0.1.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Wolfgang.Extensions.Logging.InMemoryLogger&version=0.1.3
                    
Install as a Cake Addin
#tool nuget:?package=Wolfgang.Extensions.Logging.InMemoryLogger&version=0.1.3
                    
Install as a Cake Tool

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.

NuGet NuGet downloads PR build Release License: MIT .NET GitHub


📦 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


✨ 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 (Trace through Critical).
  • Captures scope state via BeginScope for 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 generic InMemoryLogger<T> (category derived from typeof(T)), matching the standard ILogger / 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

  1. Microsoft.CodeAnalysis.NetAnalyzers — built-in .NET analyzers (correctness and performance)
  2. Roslynator.Analyzers — refactoring and code quality
  3. AsyncFixer — async/await best practices
  4. Microsoft.VisualStudio.Threading.Analyzers — thread safety
  5. Microsoft.CodeAnalysis.BannedApiAnalyzers — enforces the BannedSymbols.txt policy
  6. Meziantou.Analyzer — broad code-quality rules
  7. SonarAnalyzer.CSharp — industry-standard analysis
  8. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.3 120 7/12/2026
0.1.2 122 6/6/2026
0.1.0 116 5/2/2026
0.0.0 110 5/2/2026