Popularity
0.7
Declining
Activity
6.5
-
1
1
0

Description

向控制台输出支持自定义对象格式的日志条目.

使用Microsoft.Extensions.Logging门面库.

Programming language: C#
License: MIT License

Ac682.Extensions.Logging.Console alternatives and similar packages

Based on the "Logging" category.
Alternatively, view Ac682.Extensions.Logging.Console alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Ac682.Extensions.Logging.Console or a related project?

Add another 'Logging' Package

README

Ac682.Extensions.Logging.Console

向控制台输出支持自定义对象格式的日志条目.

使用Microsoft.Extensions.Logging门面库.

安装

Install-Package Ac682.Extensions.Logging.Console

注入

// Startup.cs

public void ConfigureService(IServiceCollection services)
{
    services.AddLogging(options => options
    {
        .AddConsole(c => c
            .SetMinimalLevel(LogLevel.Information)
            .AddBuiltinFormatters()
            .AddFormater<CustomFormatter>())
    });
}

配置

配置使用 ConsoleLoggerOptions 传入.

自定义 Formatter

本扩展使用 IObjectLoggingFormatter 序列化对象为可在控制台显示的上色文本. 自己实现该接口然后注册即可自动捕捉特定对象并发挥作用. 实现过程中缺啥构造啥,没有任何坑.