I'm currently working on a project where I want to log certain information in the Event Viewer using Log4net (EventViewerAppender). Logging with Error and Fatal gives me no trouble, but when I try to log with Info , it doesn't show up. I've checked my configuration and have looked all over the internet, but all I can find is people logging Info using a 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
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 ... >
...
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="WARN" />
<!-- FATAL ERROR WARN INFO DEBUG TRACE VERBOSE -->
<acceptOnMatch value="true" />
</filter>
</appender>
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.