Hmmmm....try this then:
public class LoggingModule : IModule
{
public void Configure(IContainer container)
{
container.ComponentRegistered += (sender, e) =>
e.ComponentRegistration.Preparing += OnComponentPreparing;
}
private static void OnComponentPreparing(object sender,
PreparingEventArgs e)
{
Type t =
e.Component.Descriptor.BestKnownImplementationType;
e.Parameters = e.Parameters.Union(new[]
{
new ResolvedParameter((p, i) => p.ParameterType ==
typeof(ILog), (p, i) => LogManager.GetLogger(t))
});
}
}
b.RegisterModule(new LoggingModule());
On Sep 4, 12:05 pm, Matt Burton <
matt.bur...@gmail.com> wrote:
> Thanks for the reply. That definitely works on a case by case basis,
> i.e. register *this* type using *this* logger, but the eventual goal
> is to come up with something generic so that I can register N services
> that all take a dependency on ILog, and have Autofac do the right
> thing supplying a logger instance for each type that declares the
> dependency. Any ideas there?
>