How do I pass a dependency to a Serilog Enricher?
问题 I'm using Serilog in my application for logging. When I'm configuring the logger, I have code like this: var log = new LoggerConfiguration() .Enrich.With<MySerilogEnricher>() .ReadAppSettings() .CreateLogger(); I want to inject some dependencies into my MySerilogEnricher class, but when I try, I get this compiler error: error CS0310: 'SerilogEnricher' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'TEnricher' in the generic type or method