Reputation: 26028
I would like to know your opinion on using MVCExtensions with Autofac..
I am using MVC Extensions with Autofac
in my MVC 3 web app
. I'm just not getting it why these extensions were created? I can't really say that it is makng my life easier. Everything that I did with Autofac in my global.asax.cs file I can do with the MVC extensions. I can register routes, controllers, my services and repositories, etc with just Autofac.
Any opinions why using these MVC extensions is maybe a better way to go?
I need to capture my errors in Application_Error
. How do I get an instance of my registered logger? If I need to resolve dependencies some where else in my app how would I do this? This is how I register my logger:
builder.RegisterType<Logger>().As<ILogger>();
I can instantiate my logger but would rather like to use the registered logger.
Is there a tag for these extensions?
Upvotes: 0
Views: 258
Reputation: 3831
You should be able to access your logger through the DependencyResolver:
var logger = DependencyResolver.Current.GetService<ILogger>();
Upvotes: 0