简体   繁体   English

log4Net XmlHierarchyConfigurator

[英]log4Net XmlHierarchyConfigurator

Am using Log4Net in my code,it start throwing this weird exception when my process run. 我在我的代码中使用Log4Net,它在我的进程运行时开始抛出这个奇怪的异常。

Here is my Appconfig for Log4Net,still am not sure what am missing here 这是我对Log4Net的Appconfig,仍然不确定这里缺少什么

It throws like 它像是一样

log4net:Error XmlHierarchyConfigurator : cannot find property[maxSizeRollBackups] to set object on [log4net.Appender.FileAppender]. log4net:错误XmlHierarchyConfigurator:找不到属性[maxSizeRollBackups]来设置[log4net.Appender.FileAppender]上的对象。

Config: 配置:

<appender name="ErrorAppender" type="log4net.Appender.FileAppender,log4net">
        <appendToFile value="true" />
        <maxSizeRollBackups value="30" />
        <maximumFileSize value="5MB" />
        <rollingStyle value="Size" />
        <staticLogFileName value="false" />
        <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
        <file value="C:\Error.log"/>
        <param name="AppendToFile" value="true"/>
        <filter type="log4net.Filter.LevelRangeFilter">
            <param name="LevelMin" value="ERROR"/>
            <param name="LevelMax" value="ERROR"/>
        </filter>
        <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="%d [%t] %-2p %c %method - %m%n"/>
        </layout>
    </appender>

更改log4net.Appender.FileAppenderlog4net.Appender.RollingFileAppender。

<appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender,log4net"> 

log4net has a feature in its configuration file where it tries to read Configuration name tags from the config file and locates them as writable properties on the class (Logger/Appender etc..) using reflection log4net在其配置文件中有一个功能,它尝试从配置文件中读取配置名称标签,并使用反射将它们定位为类(Logger / Appender等)上的可写属性

see http://mperlstein.blogspot.com/2012/04/log4net-configuration-trouble.html , I answered and explained this there. 请参阅http://mperlstein.blogspot.com/2012/04/log4net-configuration-trouble.html ,我在那里回答并解释了这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM