How do I get a serilog enricher to work with dependency injection while keeping it on startup?
问题 There is an answer here: How do I pass a dependency to a Serilog Enricher? which explains you can pass an instance in. However to do that I would need to move my logger setup after my dependency injection code has ran (in the startup.cs ) This means that startup errors won't be logged because the logger won't be ready yet. Is there a way to somehow configure serilog to run in my Main() method, but also enrich data with a DI item? The DI item has further dependencies (mainly on database