Skip to content

Expose RequestLogging-related dependency registration as a separate method #213

@julealgon

Description

@julealgon

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions