Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Provide way to have DI services participate in the logger configuration (broken with 2.0 changes) #620

Closed
epignosisx opened this issue May 12, 2017 · 2 comments

Comments

@epignosisx
Copy link

Following the announcement about the breaking changes in logging for 2.0, I noticed that we were losing the ability to add logging providers in Startup.Configure. I posted the question in the discussion issue and it was later confirmed by @davidfowl.

Before I was able to configure serilog as such:

public void Configure(ILoggerFactory factory, IHttpContextAccessor httpContextAccessor)
{
    var logger = new Serilog.LoggerConfiguration()
        .WriteTo.RollingFile("log-{Date}.txt")
        .Enrich.With(new WebEnricher(httpContextAccessor))
        .CreateLogger();

    factory.AddSerilog(logger);
}

Note how the WebEnricher depends on the IHttpContextAccessor. With the new style of configuring logging, we do not have access to DI.

@davidfowl
Copy link
Member

/cc @pakrym

@pakrym
Copy link
Contributor

pakrym commented Jun 5, 2017

Fixed via #626
You can now inject services into ILoggerProvider

@pakrym pakrym closed this as completed Jun 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants