log4net

Log4net EventLogAppender Log Event ID


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.


Solution

  • 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.