0

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?

hazzik
  • 13,019
  • 9
  • 47
  • 86
Brendan Vogt
  • 25,678
  • 37
  • 146
  • 234

1 Answers1

0

You should be able to access your logger through the DependencyResolver:

var logger = DependencyResolver.Current.GetService<ILogger>();
Alex Meyer-Gleaves
  • 3,821
  • 21
  • 11