Cognitic.Tools.Logging.InMemory 1.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Cognitic.Tools.Logging.InMemory --version 1.0.0
                    
NuGet\Install-Package Cognitic.Tools.Logging.InMemory -Version 1.0.0
                    
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="Cognitic.Tools.Logging.InMemory" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cognitic.Tools.Logging.InMemory" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Cognitic.Tools.Logging.InMemory" />
                    
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 Cognitic.Tools.Logging.InMemory --version 1.0.0
                    
#r "nuget: Cognitic.Tools.Logging.InMemory, 1.0.0"
                    
#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 Cognitic.Tools.Logging.InMemory@1.0.0
                    
#: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=Cognitic.Tools.Logging.InMemory&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Cognitic.Tools.Logging.InMemory&version=1.0.0
                    
Install as a Cake Tool

Cognitic.Tools.Logging.InMemory

This is the description of what the code block changes: Populate README.md with a project overview, features, quick start and usage instructions.

Project overview

Cognitic.Tools.Logging.InMemory is a small utility library that provides an in-memory logger implementation for Microsoft.Extensions.Logging. It is intended primarily for unit tests and diagnostics where capturing and asserting log output is useful.

Key features

  • Records log messages into a shared in-memory collection (IList<LogInfo>).
  • Simple ILoggerProvider and ILogger implementations suitable for tests.
  • Easy to register with ILoggingBuilder using the AddInMemory() extension.
  • Target: .NET8 / C#12.

Public surface

  • LogInfo � a record that represents a captured log entry. Important properties:

  • LogLevel (severity)

  • Name (logger category)

  • EventId (event identifier)

  • Exception (optional)

  • Message (formatted message)

  • InMemoryLoggerProvider � creates and caches InMemoryLogger instances.

  • InMemoryLogger � writes log entries into the shared IList<LogInfo>.

  • InMemoryLoggerExtensions.AddInMemory() � registers the provider and the shared IList<LogInfo> in the DI container.

Quick start

  1. Register the in-memory logger in your test's service collection:
IServiceCollection services = new ServiceCollection();
services.AddLogging(builder => builder.AddInMemory());

IServiceProvider provider = services.BuildServiceProvider();
var logger = provider.GetRequiredService<ILogger<Program>>();
var logs = provider.GetRequiredService<IList<LogInfo>>();

logger.LogInformation("Hello from tests");
// assert on `logs`
  1. Use logs in assertions to verify message text, level, event id or exception.

Notes and usage tips

  • The in-memory log collection is registered as a singleton IList<LogInfo>. Multiple logger instances share the same collection, which makes it convenient to assert all recorded messages across categories.
  • The provider and logger are intentionally simple and do not implement advanced features such as structured scope storage or configurable filtering beyond LogLevel.None.

Building and testing

  • This solution targets .NET8. Build and run tests using the .NET CLI:
dotnet build
dotnet test

License

MIT

Contact

Use the repository issues to report bugs or request features.

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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. 
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