Skip to content

Retrieve ILogger from IServiceProvider #5

Closed
@adamvoss

Description

@adamvoss

I read in aspnet/Logging#182 this project will use the ILogger implementation from Log.Logger if none is specified.

I understand and appreciate the need for the static/global Log; however, its seems out of place to me in cases where dependency injection is first class like in the ASP.NET 5 framework. There, it would seem more appropriate to get one from the IServiceProvider that is used for dependency resolution.

While, the current implementation works and users can choose to resolve via the DI mechanism themselves; however, I am wondering whether it would be worthwhile to have an API where serilog-framework-logging would try to resolve/retrieve the ILogger before falling back to the static Log. This could be an extension method on IApplicationBuilder that uses IApplicationBuilder.ApplicationServices meaning usage would be along the lines of app.UseSerilog().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions