无法使用值 [MinimalLock] 在对象 [log4net.Appender.RollingFileAppender] 上设置属性 [lockingModel]
我在 C# 应用程序中收到此错误。我使用 log4net 作为日志记录工具。
这是我的 app.config 文件:
<configuration>
<configSections>
<section name="log4net" type ="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="myLogger" />
</root>
<appender name="myLogger" type="log4net.Appender.RollingFileAppender,log4net">
<param name="File" value="C:\MyApp\Logs\appLog.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="2" />
<maximumFileSize value="100KB" />
<staticLogFileName value="true" />
<datePattern value="yyyyMMdd" />
<lockingModel value="log4net.Appender.FileAppender+MinimalLock" />
<immediateFlush value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
</log4net>
</configuration>
有人可以帮忙吗?
I am getting this error in my C# application. I am using log4net as a logging tool.
Here is my app.config file:
<configuration>
<configSections>
<section name="log4net" type ="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="myLogger" />
</root>
<appender name="myLogger" type="log4net.Appender.RollingFileAppender,log4net">
<param name="File" value="C:\MyApp\Logs\appLog.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="2" />
<maximumFileSize value="100KB" />
<staticLogFileName value="true" />
<datePattern value="yyyyMMdd" />
<lockingModel value="log4net.Appender.FileAppender+MinimalLock" />
<immediateFlush value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
</log4net>
</configuration>
Can anyone please help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用这个:
注意:
类型
而不是值
。Use this:
Note:
type
instead ofvalue
.当附加程序配置中有 XML 元素但附加程序中没有匹配的属性时,也可能会发生此错误。例如,
BufferingAppenderSkeleton
没有“LockingModel”属性,因此,如果它像上面的示例一样包含在 configxml 中,XmlConfigurator
将报告相同的错误如标题所示This error can also happen when there is an XML element in the appender configuration but not a matching property in the appender. For example the
BufferingAppenderSkeleton
does not have a property for "LockingModel", so if it's included in the configxml as it is in the above examples, theXmlConfigurator
will report the same error as in the title