This repository was archived by the owner on Dec 13, 2018. It is now read-only.
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
Description
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.
Metadata
Metadata
Assignees
Labels
No labels