serilog / serilog-aspnetcore

Serilog integration for ASP.NET Core
Apache License 2.0
1.31k stars 208 forks source link

Register new Logger instance with DI #180

Open cpkuo opened 4 years ago

cpkuo commented 4 years ago

If UseSerilog() is used to register a configured logger so that it resolves to Microsoft.Extensions.Logging.ILogger, then what is the recommended way to re-register it once the application is running and a new configured logger is used to replace the existing one? I am dynamically building a new logger since I also need to change source context overrides at any given point.

nblumhardt commented 4 years ago

Hi! Check out https://github.com/nblumhardt/serilog-reload for an example project showing how this might be done. Still uncertain how/when this will be integrated into Serilog.AspNetCore, but considering it for .NET 5.

nblumhardt commented 4 years ago

This is covered by: https://github.com/serilog/serilog-extensions-hosting/pull/28