Ksh.Logger.Abstractions 2024.1.3-rc.4

This is a prerelease version of Ksh.Logger.Abstractions.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Ksh.Logger.Abstractions --version 2024.1.3-rc.4                
NuGet\Install-Package Ksh.Logger.Abstractions -Version 2024.1.3-rc.4                
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="Ksh.Logger.Abstractions" Version="2024.1.3-rc.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ksh.Logger.Abstractions --version 2024.1.3-rc.4                
#r "nuget: Ksh.Logger.Abstractions, 2024.1.3-rc.4"                
#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 Ksh.Logger.Abstractions as a Cake Addin
#addin nuget:?package=Ksh.Logger.Abstractions&version=2024.1.3-rc.4&prerelease

// Install Ksh.Logger.Abstractions as a Cake Tool
#tool nuget:?package=Ksh.Logger.Abstractions&version=2024.1.3-rc.4&prerelease                

Ksh.Logger

develop main

package version downloads
Ksh.Logger NuGet NuGet
Ksh.Logger.Abstractions NuGet NuGet

The most flexible logger on the planet!

Main contents

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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