Log4Net EventLogAppender 未记录到自定义事件日志
添加了一个 EventLogAppender,如下所示:
<appender name="eventLogAppender" type="log4net.Appender.EventLogAppender,log4net" >
<mapping>
<level value="ERROR" />
<eventLogEntryType value="Error" />
</mapping>
<mapping>
<level value="DEBUG" />
<eventLogEntryType value="Information" />
</mapping>
<mapping>
<level value="INFO" />
<eventLogEntryType value="Information" />
</mapping>
<mapping>
<level value="WARN" />
<eventLogEntryType value="Warning" />
</mapping>
<logName value="NewLogName" />
<applicationName value="AppName" />
<layout type="log4net.Layout.PatternLayout,log4net">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
它创建 NewLogName
的新日志,并添加应用程序名称为 AppName
的 Windows 事件,但它将事件添加到 Application< /code> 日志而不是
NewLogName
。
我已更改注册表中的权限,并且应用程序名称位于注册表中的正确位置。有什么想法吗?
Added an EventLogAppender as follows:
<appender name="eventLogAppender" type="log4net.Appender.EventLogAppender,log4net" >
<mapping>
<level value="ERROR" />
<eventLogEntryType value="Error" />
</mapping>
<mapping>
<level value="DEBUG" />
<eventLogEntryType value="Information" />
</mapping>
<mapping>
<level value="INFO" />
<eventLogEntryType value="Information" />
</mapping>
<mapping>
<level value="WARN" />
<eventLogEntryType value="Warning" />
</mapping>
<logName value="NewLogName" />
<applicationName value="AppName" />
<layout type="log4net.Layout.PatternLayout,log4net">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
It creates the new log of NewLogName
and it adds windows events with the app name of AppName
but it adds the events to the Application
log instead of NewLogName
.
I've changed permissions in the registry and the Application Name is in the correct spot in the registry. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
启用log4net内部调试后,我没有看到任何错误。它在事件查看器中创建了
NewLogName
。没有重复的。我重新启动了事件收集器和事件日志服务,但没有解决问题。我昨晚重新启动了电脑,看起来问题已经解决了。After enabling log4net internal debugging, I didn't see any errors. It created the
NewLogName
in the Event Viewer. There is no duplicate. I restarted the Event Collector and the Event Log services and it didn't fix it. I rebooted my computer last night and it looks like that fixed it.