I’m setting up logging in an MVC project. My class NLogLogger takes a parameter of type [Type]. Is there anyway that I can get autofac to instantiate the NLogLogger object passing in the type of the Controller that is currently being instantiated? In the code below, TTT needs to be the Type of the controller.
builder.Register(c => new NLogLogger(TTT)).As<ILogger>();
builder.RegisterControllers(Assembly.GetExecutingAssembly());
Thanks very much for your help.
Damien.
You should be able to solve this in the same way as the Log4NetIntegration works. You set up a
Modulethat listens in on every component preparation (when some instance is about to be created by the container) and supply the NLog logger for the component type.