You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd propose an enhancement to the middleware so that an instance of a logger can be provided and that used to get log context instead --> falling back to the static Log.Logger if no instance provided might be a good way to keep this a backwards compatible change?
The text was updated successfully, but these errors were encountered:
Hi @dazinator - would accepting an ILogger through RequestLoggingMiddlewareOptions work with the startup sequence you're using? Just had a look at the effort involved, seems minimal, spiked a PR.
I am trying to use only instances of ILogger. As such I wondered what would happen if I never set
Log.Logger.
I found was now getting no request logging. Looking at the request logging middleware it looks like Log.Logger needs to be set first as it uses Log.ForContext: https://github.com/serilog/serilog-aspnetcore/blob/dev/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs#L76 and if Log.Logger isn't set this yields SilentLogger's. (To be honest I would think it would be better to throw an exception in such a case as logging not being initialised is pretty important)
I'd propose an enhancement to the middleware so that an instance of a logger can be provided and that used to get log context instead --> falling back to the static Log.Logger if no instance provided might be a good way to keep this a backwards compatible change?
The text was updated successfully, but these errors were encountered: