I'm not very familiar with the Event Log so bear with me... I looked at some entries in the Event Log on my computer and saw that for similiar messages, the Event ID was always the same. I thought the Event ID was similiar to a primary key in a database. In other words I thought that I could somehow query the Event Loger for a particular event based on its Event ID:
// WRONG ??? EventLogEntry eventLogEntry = eventLog.GetEvent(eventId); but it looks like that's not the case. Are you wanting to set a default Event ID for your application? <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" > <layout type="log4net.Layout.SimpleLayout" /> <eventId value="5" /> </appender> Or setup default Event IDs in such a way that each log4net Level has its own default EventId? <appender name="InfoEventLogAppender" type="log4net.Appender.EventLogAppender" > <layout type="log4net.Layout.SimpleLayout" /> <eventId value="10" /> ... </appender> <appender name="WarnEventLogAppender" type="log4net.Appender.EventLogAppender" > <layout type="log4net.Layout.SimpleLayout" /> <eventId value="100" /> ... </appender> <appender name="ErrorEventLogAppender" type="log4net.Appender.EventLogAppender" > <layout type="log4net.Layout.SimpleLayout" /> <eventId value="1000" /> ... </appender> --- Billy Barnum <[EMAIL PROTECTED]> wrote: > That doesn't look to bad, you're correct. But I'll have to read in > the SDK > about use of these ThreadContext properties; I'm still too new around > here > to see how such properties pass through to an EventLog.WriteEntry() > or > whatever. Thank you once again. > > As long as you're asking: yes, I propose that eventID is such an > integral > part of writing to Windows event logs that it should be exposed more > easily. > I think a single integer parameter would be sufficient; after all the > resource which EventLogAppender wraps only accepts integers. > > WILLIAM BARNUM > [EMAIL PROTECTED] > > > -----Original Message----- > From: Ron Grabowski [mailto:[EMAIL PROTECTED] > Sent: Friday, September 23, 2005 1:43 PM > To: Log4NET User > Subject: RE: How to log EventID with EventLogAppender? > > The extension folder name may be misleading. The implementation isn't > very complex: > > public void Info(int eventId, object message, System.Exception t) > { > if (this.IsInfoEnabled) > { > LoggingEvent loggingEvent = new LoggingEvent(...); > loggingEvent.Properties["EventID"] = eventId; > Logger.Log(loggingEvent); > } > } > > You could do basically the same thing using the normal ILog > interface: > > log4net.ThreadContext.Properties["EventId"] = 5; > log.Info("Hello World"); > > using(log4net.ThreadContext.Stacks["EventId"].Push("5")) > { > log.Info("Hello World"); > } > > How do you propose this functionality be made part of the core? Do > you > think the ILog interface members should be modified to accept a > single > integer parameter? What if someone's EventId is a float, GUID, or a > string? > > > >
