Ksh.Logger
2024.1.3-rc.3
See the version list below for details.
dotnet add package Ksh.Logger --version 2024.1.3-rc.3
NuGet\Install-Package Ksh.Logger -Version 2024.1.3-rc.3
<PackageReference Include="Ksh.Logger" Version="2024.1.3-rc.3" />
paket add Ksh.Logger --version 2024.1.3-rc.3
#r "nuget: Ksh.Logger, 2024.1.3-rc.3"
// Install Ksh.Logger as a Cake Addin #addin nuget:?package=Ksh.Logger&version=2024.1.3-rc.3&prerelease // Install Ksh.Logger as a Cake Tool #tool nuget:?package=Ksh.Logger&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
- Ksh.Logger.Abstractions (>= 2024.1.3-rc.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
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 |
---|---|---|
2024.2.2-rc.1 | 28 | 5/2/2024 |
2024.2.1 | 81 | 5/2/2024 |
2024.1.3 | 126 | 3/23/2024 |
2024.1.3-rc.4 | 60 | 3/18/2024 |
2024.1.3-rc.3 | 56 | 3/18/2024 |
2024.1.2 | 118 | 3/18/2024 |
2024.1.2-rc.2 | 54 | 3/18/2024 |
2024.1.1 | 126 | 3/18/2024 |