Created
May 26, 2016 11:31
-
-
Save sshibani/604642472693b815c57c7412a4b7ae30 to your computer and use it in GitHub Desktop.
NLog Autofac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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