Huanent Logging Save

microsoft.extensions.logging日志组件拓展

Project README

Microsoft.Extensions.Logging extensions

Install

Nuget Nuget

Usage

Huanent.Logging.Core

public class ConsoleLogWriter : ILogWriter
{
    public void WriteLog(LogLevel level, string message, string name, Exception exception, EventId eventId)
    {
        Console.WriteLine($"From {nameof(ConsoleLogWriter)} {level} {message} {name} {exception} {eventId}");
    }
}

//ILoggingBuilder
logging.AddImplementation<ConsoleLogWriter>();

Huanent.Logging.File

//ILoggingBuilder
logging.AddFile();

Log will out in {application folder}/logs/20211020.txt

[Error] [LoggingFileSample.Worker] [0] [2021/10/20 01:05:35 +00:00]
Worker running at: 10/20/2021 21:05:35 +08:00
System.Exception: error

[Error] [LoggingFileSample.Worker] [0] [2021/10/20 01:05:36 +00:00]
Worker running at: 10/20/2021 21:05:36 +08:00
System.Exception: error

[Error] [LoggingFileSample.Worker] [0] [2021/10/20 01:05:37 +00:00]
Worker running at: 10/20/2021 21:05:37 +08:00
System.Exception: error
Open Source Agenda is not affiliated with "Huanent Logging" Project. README Source: huanent/Logging
Stars
33
Open Issues
1
Last Commit
11 months ago
Repository

Open Source Agenda Badge

Open Source Agenda Rating