有许多使用应用程序设置配置来配置接收器及其属性的示例。但是,我无法真正通过应用程序设置配置自定义浓缩器。能做到吗?我尝试使用类和程序集名称的完整路径来指定配置,但似乎不起作用。这是我尝试使用的配置示例:
<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" />
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句