tags:

views:

291

answers:

2

Hi. Is there a way to log an event into the windows event log with a specified eventid per message? I am using log4net v 1.2.10.

+1  A: 

Based on what I see in the EventLogAppender source code the following should do the trick:

log4net.ThreadContext.Properties["EventId"] = 5;

Just call this before you write your log messages (if you do not set it for all messages you should remove the "EventID" again from the Properties.

Stefan Egli
A: 

Well, the solution was to build the extension project "log4net.Ext.EventID" and to use its types: IEventIDLog, EventIDLogImpl and EventIDLogManager.

Markus