NLog单身人士到温莎城堡

时间:2014-08-16 11:25:43

标签: castle-windsor ioc-container nlog

我遇到了CastleWindsor Installer的问题。现在我有Nlog记录器的课程。

public class Log
{
    public static Logger Instance = LogManager.GetCurrentClassLogger();
}

我希望将此转换为城堡,但我无法弄清楚如何为此案例创建IWindsorInstaller。

1 个答案:

答案 0 :(得分:0)

Castle Logging Facility与Castle NLog集成(均可从nuget获得)一起使用。然后,您可以将接口Castle.Core.Logging.ILogger注入到对象中。你不会使用实际的NLog ILogger,而是使用Castle Windsor的抽象。

我现在无法在办公室访问我的git repo进行检查,但这应该是要添加到WindsorInstaller的行:

container.AddFacility<LoggingFacility>(f => f.LogUsing(LoggerImplementation.NLog).WithConfig("nlog.config"));