当与放大器;如何城堡温莎设置日志记录工具 [英] Where & How Castle Windsor sets up logging facility

查看:359
本文介绍了当与放大器;如何城堡温莎设置日志记录工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是相当新的温莎城堡,我期待到中的进出的记录设施。它似乎相当IM pressive,但我不能工作了,唯一就是温莎设置上我的课的记录器属性。如下面的code将记录仪设置为nullLogger如果类还没有安装,但还没有解决时,完成运行记录器属性设置。

I'm fairly new to Castle Windsor and am looking into the in's and out's of the logging facility. It seems fairly impressive but the only thing i can't work out is where Windsor sets the Logger property on my classes. As in the following code will set Logger to the nullLogger if the class hasn't been setup yet but when Resolve is finished running the Logger property is set.

private ILogger logger;

public ILogger Logger
{
    get
    {
        if (logger == null) 
            logger = NullLogger.Instance;
        return logger;
    }
    set { logger = value; }
}

那么,我想知道是如何以及在何处温莎设置我的记录器属性。

So what I am wondering is how and where windsor sets my Logger property.

干杯 安东尼

推荐答案

该记录仪是安装程序的日志记录功能,这是在<设备>的部分组态。例如使用log4net的你的应用程序或web.config文件看起来是这样的:

The logger is setup by the logging facility, which is in the <facilities> section of the configuration. For example to use log4net your app or web.config would look something like this:

<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/>
    </configSections>
<Configuration>

<castle>

    <facilities>
        <facility id="loggingfacility" 
             type="Castle.Facilities.Logging.LoggingFacility, Castle.Facilities.Logging" 
             loggingApi="log4net" 
             configFile="logging.config" />
    </facilities>

</castle>
</configuration>

这篇关于当与放大器;如何城堡温莎设置日志记录工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆