Meziantou.Extensions.Logging.InMemory
1.2.1
Prefix Reserved
dotnet add package Meziantou.Extensions.Logging.InMemory --version 1.2.1
NuGet\Install-Package Meziantou.Extensions.Logging.InMemory -Version 1.2.1
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="Meziantou.Extensions.Logging.InMemory" Version="1.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Meziantou.Extensions.Logging.InMemory --version 1.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Meziantou.Extensions.Logging.InMemory, 1.2.1"
#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.
// Install Meziantou.Extensions.Logging.InMemory as a Cake Addin #addin nuget:?package=Meziantou.Extensions.Logging.InMemory&version=1.2.1 // Install Meziantou.Extensions.Logging.InMemory as a Cake Tool #tool nuget:?package=Meziantou.Extensions.Logging.InMemory&version=1.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Meziantou.Extensions.Logging.InMemory
using var loggerProvider = new InMemoryLoggerProvider();
var logger = loggerProvider.CreateLogger("MyLogger");
// do stuff with the logger
// Assert
Assert.Empty(loggerProvider.Logs.Errors);
Assert.Single(loggerProvider.Logs, log => log.Message.Contains("test") && log.EventId.Id == 1);
If you are using a WebApplicationFactory
:
using var loggerProvider = new InMemoryLoggerProvider();
using var factory = new WebApplicationFactory<Program>()
.WithWebHostBuilder(builder =>
{
builder.ConfigureLogging(builder =>
{
// You can override the logging configuration if needed
//builder.SetMinimumLevel(LogLevel.Trace);
//builder.AddFilter(_ => true);
builder.Services.AddSingleton<ILoggerProvider>(loggerProvider);
});
});
Blog post about testing logging: How to test the logs from ILogger in .NET
Product | Versions 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 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Meziantou.Extensions.Logging.InMemory:
Repository | Stars |
---|---|
mehdihadeli/vertical-slice-api-template
An asp.net core template based on .Net 8, Vertical Slice Architecture, CQRS, Minimal APIs, API Versioning and Swagger.
|