Autofac Loggging Module for NLog
Nuget package available, to install run the following command;
Install-Package Autofac.Extras.NLogRegister NLogModule to Autofac
It attaches to Component Registration and creates logger for requested type.
containerBuilder.RegisterModule<NLogModule>();Register SimpleNLogModule to Autofac
It is useful when ILogger resolved from Service Locator.
containerBuilder.RegisterModule<SimpleNLogModule>();NLogModule and SimpleNLogModule supports both constructor and property injection.
- Constructor sample
public class SampleClassWithConstructorDependency : ISampleInterface
{
private readonly ILogger _logger;
public SampleClassWithConstructorDependency(ILogger logger)
{
_logger = logger;
}
}- Property Sample
public class SampleClassWithPropertyDependency : ISampleInterface
{
public ILogger Logger { get; set; }
}- Service Locator Sample
public class SampleClassToResolveLoggerFromServiceLocator : ISampleClass
{
private readonly ILogger _logger;
public SampleClassToResolveLoggerFromServiceLocator(ILifetimeScope serviceLocator)
{
_logger = serviceLocator.Resolve<ILogger>();
}
}

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
