[英]Log Info in Event Viewer using Log4net
I'm currently working on a project where I want to log certain information in the Event Viewer using Log4net (EventViewerAppender). 我目前正在一个项目中,我想使用Log4net(EventViewerAppender)在事件查看器中记录某些信息。 Logging with Error and Fatal gives me no trouble, but when I try to log with Info , it doesn't show up.
使用Error and Fatal登录不会给我带来麻烦,但是当我尝试使用Info登录时,它不会显示。 I've checked my configuration and have looked all over the internet, but all I can find is people logging Info using a FileAppender.
我检查了配置,并在整个Internet上进行了查找,但我只能找到使用FileAppender记录信息的用户。
I'm using the following configuration in my config file: 我在配置文件中使用以下配置:
<log4net>
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
<layout type="log4net.Layout.Patternlayout">
<conversionPattern value="%date %-5level %logger - %message%newline " />
</layout>
<level value="ALL" />
<logName value="Services"/>
<applicationName value="MyApplication"/>
</appender>
<root>
<level value="ALL"/>
<appender-ref ref="EventLogAppender"/>
</root>
</log4net>
I'm not sure what I'm doing wrong here, so any help would be helpful. 我不确定自己在做什么错,因此任何帮助都会有所帮助。
Thanks! 谢谢! -dckwlff
-dckwlff
EDIT 编辑
Seems I had it working all along, but was looking at the wrong view in the Event Viewer. 似乎我一直都在工作,但是在事件查看器中看错了视图。
Try to set a LevelRangeFilter for appender: 尝试设置Appender的LevelRangeFilter:
<appender ... >
...
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="WARN" />
<!-- FATAL ERROR WARN INFO DEBUG TRACE VERBOSE -->
<acceptOnMatch value="true" />
</filter>
</appender>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.