C# log4Net XmlHierarchyConfigurator
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9509586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
log4Net XmlHierarchyConfigurator
提问by Usher
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:Error 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>
采纳答案by Min Min
Change log4net.Appender.FileAppenderto log4net.Appender.RollingFileAppender.
更改log4net.Appender.FileAppender到log4net.Appender.RollingFileAppender。
<appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender,log4net">
回答by Mickey Perlstein
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,我在那里回答并解释了这一点。

