Description
The existing UseSerilog
overloads do not provide access to the underlying IServiceProvider
and thus don't support any kind of dependency injection.
I needed to check a settings class on my side using IOptions<T>
and use these values as paraments to sink configuration. I ended up moving the log configuration into the startup class, dropping the use of UseSerilog
and instead relying on ILoggerFactory.AddSerilog
inside a custom configuration class that I injected inside the Startup's Configure
method.
If the IServiceProvider
used in the singleton registration inside UseSerilog
was exposed as one of the parameters, I could've leveraged that to fetch my options instead.
From what I gathered from the implementation, it would just be a matter of moving some of the code inside the AddSingleton
lambda, firing the user-provided lambda there and thus having access to the IServiceProvider
.