serilog-aspnetcore
serilog-aspnetcore copied to clipboard
Expose RequestLogging-related dependency registration as a separate method
Is your feature request related to a problem? Please describe.
Currently, this library exposes a UseSerilogRequestLogging
method to be used inside the Configure
method, but does not expose a method to add the necessary registrations to the container to make it work properly. Usually, "features" added in Configure
should have an equivalent AddX
extension to be used inside ConfigureServices
so that all required dependencies are registered.
I understand the UseSerilog
on IHostBuilder
includes those registrations, but that happens somewhere else. Perhaps UseSerilog
could call into the same method to register the needed classes.
Describe the solution you'd like
Add a new extension method for IServiceCollection
to register the needed types for the request logging logic (for example, DiagnosticContext
)
Describe alternatives you've considered
Calling UseSerilog
on the IHostBuilder
does register the necessary dependencies, but it forces changes on Program.cs
for cases where one wants to configure the logger inside Startup
.
Hi @julealgon - thanks for the suggestion! Post-.NET 5.0 I'll take a look at this - in the meantime I think we will want to stay close to the host builder in the expectation that host-level logging is going through some churn and we may need to hook into it more deeply in the future.