serilog / serilog-settings-configuration

A Serilog configuration provider that reads from Microsoft.Extensions.Configuration
Apache License 2.0
455 stars 129 forks source link

System.MemberAccessException if enricher has static ctor #260

Closed Tolyandre closed 3 years ago

Tolyandre commented 3 years ago

If a custom enricher has a static ctor, configuration throws System.MemberAccessException : Type initializer was not callable.

There is how I discovered such behavior: https://github.com/Tolyandre/serilog-throw-context-enricher/issues/2

To reproduce with a unit test:

  1. add empty static ctor to DummyThreadIdEnricher
  2. run test EnrichWithIsAppliedWithCustomEnricher

Actual behavior: test throws Expected behavior: enricher is instantiated

nblumhardt commented 3 years ago

Thanks for the report 👍