Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateBootstrapLogger doesn't work with non-static Logger #74

Closed
gkinsman opened this issue Jun 27, 2023 · 2 comments
Closed

CreateBootstrapLogger doesn't work with non-static Logger #74

gkinsman opened this issue Jun 27, 2023 · 2 comments

Comments

@gkinsman
Copy link

gkinsman commented Jun 27, 2023

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 :)

#if !NO_RELOADABLE_LOGGER
var reloadable = Log.Logger as ReloadableLogger;
var useReload = reloadable != null && !preserveStaticLogger;
#else

@nblumhardt
Copy link
Member

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
Copy link
Member

Closing this one as stale, hope you were able to figure out a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants