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
{{ message }}
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.
Currently when ILoggerFactory is not registered in the IoC container the Cookies middleware throws a null reference exception as this is a compulsory parameter. This has to be an optional parameter if the app does not want to do any logging.
The text was updated successfully, but these errors were encountered:
If we inject ILoggerFactory via DI, you can't make it optional.
Hosting should provide an implementation, even if it's a NullLoggerFactory that returns a NullLogger. Individual middleware shouldn't have to deal with this.
Consider defining NullLoggerFactory in the Logging assembly.
Yeah I'm not sure whether we want to use a null object pattern here or not. There are certainly both pros and cons (having to write null checks vs. unnecessary calls into a black hole).
As far as being optional with DI, there are two ways to achieve this:
Instead of injecting, use GetService (and catch exceptions if it throws)
Take in an IEnumerable<ILoggerFactory> and check that you got either 0 or 1 back.
I'm sure that within minutes both @lodejard and @davidfowl will read this and have simultaneous heart attacks 💔 💔 but I'm curious what they'll say.
Currently when ILoggerFactory is not registered in the IoC container the Cookies middleware throws a null reference exception as this is a compulsory parameter. This has to be an optional parameter if the app does not want to do any logging.
The text was updated successfully, but these errors were encountered: