Ksh.Logger.Abstractions
2024.1.3-rc.3
See the version list below for details.
dotnet add package Ksh.Logger.Abstractions --version 2024.1.3-rc.3
NuGet\Install-Package Ksh.Logger.Abstractions -Version 2024.1.3-rc.3
<PackageReference Include="Ksh.Logger.Abstractions" Version="2024.1.3-rc.3" />
paket add Ksh.Logger.Abstractions --version 2024.1.3-rc.3
#r "nuget: Ksh.Logger.Abstractions, 2024.1.3-rc.3"
// Install Ksh.Logger.Abstractions as a Cake Addin #addin nuget:?package=Ksh.Logger.Abstractions&version=2024.1.3-rc.3&prerelease // Install Ksh.Logger.Abstractions as a Cake Tool #tool nuget:?package=Ksh.Logger.Abstractions&version=2024.1.3-rc.3&prerelease
Ksh.Logger
The most flexible logger on the planet!
Simple usage
var propagators = new List<ILogMessagePropagator> {
new ConsoleLoggerPropagator(),
new FileLoggerPropagator("path.to.log")
};
var logger = new StandardLogger(propagators);
logger.Info("hello world");
It looks simpler, but you have also the direct dependencies and violate the DIP (dependency inversion principle).
Using with Microsoft Dependency Injection
var services = new ServiceCollection();
services.AddKshLogger();
var kernel = services.BuildServiceProvider();
var loggerFactory = kernel.GetService<ILoggerFactory>()!;
loggerFactory.AddConsoleLogger();
loggerFactory.AddFileLogger("path.to.log");
var logger = loggerFactory.CreateLogger();
logger.Info("hello world");
You are already ready to log into a file as well as into console. Of course, you can skip the console or the file logger if you wish.
Customization
As mentioned, this Logger is very flexible. It is even possible to connect multiple existing logging frameworks.
Propagators
The power of this Logger are the Propagators
Here is an example, how to be notified if your crashed and reported a fatal error.
public class CustomPropagator(IEmailClient emailClient) : ILogMessagePropagator
{
public void Propagate(LogMessage message)
{
if (message.Severity == LogSeverity.Fatal)
{
emailClient.SendEmail(message.Message);
}
}
}
Just put this propagator into your factory or directly into the logger.
loggerFactory.AddPropagator(new CustomPropagator(emailClient));
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. |
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Ksh.Logger.Abstractions:
Package | Downloads |
---|---|
Ksh.Logger
The most flexible logger on earth |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2024.2.2-rc.1 | 25 | 5/2/2024 |
2024.2.1 | 84 | 5/2/2024 |
2024.1.3 | 139 | 3/23/2024 |
2024.1.3-rc.4 | 65 | 3/18/2024 |
2024.1.3-rc.3 | 62 | 3/18/2024 |
2024.1.2 | 139 | 3/18/2024 |
2024.1.2-rc.2 | 58 | 3/18/2024 |
2024.1.1 | 132 | 3/18/2024 |