当与放大器;如何城堡温莎设置日志记录工具放大器、城堡、温莎、工具

2023-09-02 23:47:24 作者:起个好听的,超好听的大全

我是相当新的温莎城堡,我期待到中的进出的记录设施。它似乎相当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>