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

UseSerilog implementation #163

Closed
dazinator opened this issue Jan 16, 2020 · 1 comment
Closed

UseSerilog implementation #163

dazinator opened this issue Jan 16, 2020 · 1 comment

Comments

@dazinator
Copy link

dazinator commented Jan 16, 2020

Hello it's me again!

I couldn't use UseSerilog() in my application for reasons delved into here (my application is complex using autofac and child containers, and my own library for multitenancy) - and my workaround was to do this instead:

               webhostBuilder.ConfigureLogging((logging) =>
                {
                    logging.ClearProviders();// clears microsoft providers registered by default like console.
                    logging.AddSerilog(Logger);
                });

Which works. I raise this here because I thought maybe you could simplify the UseSerilog() implementation to call this method on the host builder instead, and then you could ditch your custom ILoggerFactory ?

@nblumhardt
Copy link
Member

Thanks for the note! The workaround you're using is the supported one, here; we deliberately use our own ILoggerFactory to avoid inconsistencies/edge cases around filtering and configuration, but the Serilog provider works when the default approach isn't viable 👍

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