The EventLogAppender looks for a custom property on the LoggingEvent
called 'EventID'. You can set this value before making a logging call as
follows:

log4net.ThreadContext.Properties["EventID"] = 12;
log.Info("My Message");

However this is verbose and does leave the EventID set for all
subsequent log calls (on the current thread). You would need to set the
property before each log call.

There is an alternative which is an extension to log4net to allow you to
pass the EventID in to the logging call itself. This means that you
don't have to set the property directly. The extension is included in
the log4net download in source form only. Have a look at
extensions\net\1.0\log4net.Ext.EventID\cs\src in the download. The
EventIDLogManager should be used to request loggers and as the
IEventIDLog interface extends the default ILog interface this can be
used for normal logging as well.

I suggest that you give the EventID extension a try.

Nicko

> -----Original Message-----
> From: Jeremiah Voris [mailto:[EMAIL PROTECTED] 
> Sent: 20 July 2005 21:52
> To: Log4NET User
> Subject: Re: How do I set Category/Event in EventLogAppender?
> 
> On 7/19/05, Jeremiah Voris <[EMAIL PROTECTED]> wrote:
> > I may be blind but I just can't find it in the documentation. Can 
> > someone help me figure this out?
> 
> I'm looking at the EventLotAppender Class documentation and I 
> found this:
> 
>   The EventID of the event log entry can be set using the 
> EventLogEventID property (Properties) on the LoggingEvent.
> 
> but I still can't figure out how that translates to code. I'm 
> assuming there is a way to get at the EventLogEventID 
> property before I issue the log.x() command? I can't find 
> anything that looks right though...
> 
> --
> 533777336444244
> 

Reply via email to