serilog-aspnetcore icon indicating copy to clipboard operation
serilog-aspnetcore copied to clipboard

Register new Logger instance with DI

Open cpkuo opened this issue 4 years ago • 2 comments

If UseSerilog() is used to register a configured logger so that it resolves to Microsoft.Extensions.Logging.ILogger<T>, 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.

cpkuo avatar Mar 10 '20 19:03 cpkuo

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 avatar Jul 25 '20 00:07 nblumhardt

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

nblumhardt avatar Oct 07 '20 23:10 nblumhardt