简体   繁体   中英

log4Net XmlHierarchyConfigurator

Am using Log4Net in my code,it start throwing this weird exception when my process run.

Here is my Appconfig for Log4Net,still am not sure what am missing here

It throws like

log4net:Error XmlHierarchyConfigurator : cannot find property[maxSizeRollBackups] to set object on [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

see http://mperlstein.blogspot.com/2012/04/log4net-configuration-trouble.html , I answered and explained this there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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