Skip to content

Instantly share code, notes, and snippets.

@sshibani
Created May 26, 2016 11:31
Show Gist options
  • Save sshibani/604642472693b815c57c7412a4b7ae30 to your computer and use it in GitHub Desktop.
Save sshibani/604642472693b815c57c7412a4b7ae30 to your computer and use it in GitHub Desktop.
NLog Autofac
public class NLogModule : Module
{
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
registration.Preparing += OnComponentPreparing;
}
private static void OnComponentPreparing(object sender, PreparingEventArgs e)
{
var t = e.Component.Activator.LimitType;
e.Parameters = e.Parameters.Union(
new[]
{
new ResolvedParameter((p, i) => p.ParameterType == typeof (DD4T.ContentModel.Contracts.Logging.ILogger),
(p, i) => new NLog(LogManager.GetLogger(t.FullName)))
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment