Autofac.Extras.NLog
Autofac.Extras.NLog copied to clipboard
Does SimpleNLogModule exist?
Hello and thank you for this tool. I have a problem with resolving ILogger with IServiceProvider. My implementation is pretty simple:
public class ServiceProvider : IServiceProvider
{
private readonly ILifetimeScope scope;
public ServiceProvider(ILifetimeScope scope)
{
this.scope = scope;
}
public object GetService(Type serviceType)
{
return scope.Resolve(serviceType);
}
}
and this is registration part:
var builder = new ContainerBuilder();
builder.RegisterModule<NLogModule>();
builder.RegisterType<ServiceProvider>().As<IServiceProvider>();
Types registered with RegisterType are resolved well, but when I try to resolve ILogger I got "The requested service 'NLog.ILogger' has not been registered" exception. If ILogger is injected as constructor parameter then is resolved well as part of ASP.NET DI. What am I doing wrong?
Your Readme says that there is SimpleNLogModule that "is useful when ILogger resolved from Service Locator". But it looks like it doesn't exist any more.
Hello @ziyasal, can you help with that?