繁体   English   中英

使用Serilog XML配置指定自定义浓缩器

[英]Specifying a custom enricher using Serilog XML configuration

有许多使用应用程序设置配置配置接收器及其属性的示例。 但是,我无法通过应用程序设置真正地围绕配置自定义浓缩器。 可以这样做吗? 我试图使用我的类和程序集名称的完整路径来指定配置,但它似乎不起作用。 这是我尝试使用的配置示例:

<add key="serilog:enrich:with" value="MyApp.Logging.Serilog.MyEnricher, MyApp" />

键值对语法当前需要为此案例定义的扩展方法才能工作,例如:

static class MyLoggerEnrichmentConfigurationExtensions
{
    public static LoggerConfiguration WithMyEnricher(this LoggerEnrichmentConfiguration enrich)
    {
        return enrich.With(new MyEnricher());
    }
}

然后引用它并像这样调用:

<add key="serilog:using:MyApp" value="MyApp" />
<add key="serilog:enrich:WithMyEnricher" />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM