-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
No instance of ILoggerFactory found in serviceCollection. #272
Comments
ok |
I've had a developer also report this as we migrate apps from .Net Framework 4.x and using a homegrown log4net adapter, to .Net Core 2.x and trying to use |
The implementation of attaching the Microsoft logger factory to logging from CacheManager is a bit flaky for historical reasons. I'm not really sure yet how to change that in a good way but I'll have a look into that again |
With Microsoft.Extensions.Logging it seems like CacheManager having its own logging abstraction is a bit redundant; the point of ILogger and ILoggerFactory is to allow apps to chose their underlying logging impl without coupling code to any one. |
Not really, I don't want to have a hard dependency on any external library in the base code because that would move that dependency up the chain to everything and everyone using CM. I think the wrapper for the logging calls from my internal loggers to the Microsoft logger is totally fine, its very simple and doesn't do much. |
I understand, but I'd say that most .Net Core apps are likely already using Mocrosoft.Extensions.ILogger anyway. |
In either case, if the setup portion gets fixed, I request that it be back-ported into a 1.x release. My client and our project can not tolerate the major upgrade to CM any time soon but we definitely need .Net Core compatible logging through ILogger. |
This seems to work fine in a .Net Core app (tested in 2.1 and 2.2): |
Bringing this old issue back up but if there was an overload that provides
Usage
|
run AspnetCore.WebApp,page error:No instance of ILoggerFactory found in serviceCollection.
change
services.AddCacheManagerConfiguration(Configuration, cfg => cfg.WithMicrosoftLogging(services));
toservices.AddCacheManagerConfiguration(Configuration);
is ok.The text was updated successfully, but these errors were encountered: