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

Inject ILogger into RequestLoggingMiddleware #214

Open
julealgon opened this issue Oct 21, 2020 · 4 comments
Open

Inject ILogger into RequestLoggingMiddleware #214

julealgon opened this issue Oct 21, 2020 · 4 comments

Comments

@julealgon
Copy link

Is your feature request related to a problem? Please describe.
The way RequestLoggingMiddleware currently fetches the ILogger instance is through the options class and fallback to the static logger. I believe this design forces unnecessary changes when using non-static registrations for Serilog as it forces one to manually pass in the ILogger instance on the UseSerilogRequestLogging call.

Describe the solution you'd like
Make it so that ILogger is injected into the middleware by the standard dependency injection mechanism, so that any registered ILogger is naturally used without requiring manual wiring.

Describe alternatives you've considered
I'm personally not fond of dealing with static variables, so while I understand this is not an issue when using Log.Logger, I'd rather not do that in my projects if at all possible.

To make it work, I had to manually inject ILogger into the Configure method and pass it along in the configuration delegate.

@nblumhardt
Copy link
Member

Thanks for the suggestion, I think this was raised previously, we can take another look 👍

@sungam3r
Copy link
Contributor

It was raised by me.

@julealgon
Copy link
Author

I wasn't aware this had been raised previously. If there is a duplicate issue, please feel free to close @nblumhardt / @sungam3r .

@sungam3r
Copy link
Contributor

sungam3r commented Nov 2, 2020

It was raised here #183 (comment)

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

No branches or pull requests

3 participants