I am trying to replace dryIOC container with autofac container for some reason but I don't know the exact syntax how could I resolve ILogger uisng autofac
Here is how I register ILogger in DryIoc
public void Load(IContainer container)
{
container.Register<ILoggerFactory, Log4NetLoggerFactory>();
ConfigureLogger(container);
}
[Localizable(false)]
private void ConfigureLogger(IContainer container)
{
container.Register<ILogger>(
made: Made.Of(
r => typeof(ILoggerFactory).GetMethod(nameof(ILoggerFactory.Create), new[] { typeof(Type) }),
factoryInfo: ServiceInfo.Of<ILoggerFactory>(),
parameters: Parameters.Of.Name("type", r => r.Parent?.ImplementationType ?? typeof(Startup))),
reuse: Reuse.Transient);
}
I have tried something like this, but it does not work with Autofac
container.Register<ILoggerFactory, Log4NetLoggerFactory>();