Set Event ID per log when writing to Windows Event Log

混江龙づ霸主 提交于 2019-12-01 09:03:21

I figured it out - you have to use a layout in the eventId property of the target:

<target xsi:type="EventLog"
  name="EventLog"
  layout="${longdate:universalTime=true}|${level:uppercase=true}|${logger}|${message}"
  source="MyApp"
>>  eventId="${event-properties:EventID}" <<
  log="Application" />

I've also created the Timber logging facade called for both NLog and log4net, which makes logging messages with different event IDs very simple.

On the github hub repo there's an example config for EventLog targets that includes an eventId. The eventId will use a Layout that renders an event ID.

https://github.com/NLog/NLog/wiki/Eventlog-target

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!