serilog-extensions-hosting icon indicating copy to clipboard operation
serilog-extensions-hosting copied to clipboard

CreateBootstrapLogger doesn't work with non-static Logger

Open gkinsman opened this issue 1 year ago • 1 comments

Hi there!

I'm kicking the tyres on CreateBootstrapLogger so that we can pull our log sink config from a secure store. To support parallel test running we don't use a static logger and instead inject it, but I don't see an override of UseSerilog/AddSerilog that accepts both an ILogger and a reconfiguration callback.

This code appears to only check to see if the static logger exists - should there perhaps be an overload that just accepts an ILogger and checks if it or the static logger is reloadable? Happy to add it if this is the right way to go :)

https://github.com/serilog/serilog-extensions-hosting/blob/52f29a676444e58015863ab92c1432357d0fa03f/src/Serilog.Extensions.Hosting/SerilogServiceCollectionExtensions.cs#L141-L144

gkinsman avatar Jun 27 '23 14:06 gkinsman

Thanks for the note, @gkinsman! Sorry about the slow reply - just got back from a short vacation :-)

I might need a bit more context around what your test code looks like, I'm not sure I can really wrap my head around the scenario.

Just to try to fill in the picture - if you have an ILogger already in hand, could you (for example) try casting it to ReloadableLogger and call Reload yourself, before passing it through to AddSerilog?

nblumhardt avatar Jul 05 '23 08:07 nblumhardt