Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log4net EventLogAppender Log Event ID

Tags:

log4net

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.

like image 349
Markus Avatar asked Feb 18 '10 16:02

Markus


1 Answers

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.

N.B the property key is case sensitive.

like image 190
Stefan Egli Avatar answered Oct 16 '22 20:10

Stefan Egli