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?

--- Billy Barnum <[EMAIL PROTECTED]> wrote:

> Ah, an extension. I was hoping to avoid that. You'd think that'd be
> part of
> the core. Nevermind, though. I'll check it out - and thank you very
> much.
> 
> 
> 
> WILLIAM BARNUM
> [EMAIL PROTECTED]
>  
> 
> -----Original Message-----
> From: Ron Grabowski [mailto:[EMAIL PROTECTED] 
> Sent: Friday, September 23, 2005 1:04 PM
> To: Log4NET User
> Subject: Re: How to log EventID with EventLogAppender?
> 
> Do you want to do something like this:
> 
>  public interface IEventIDLog : ILog
>  {
>   void Info(int eventId, object message);
>   void Info(int eventId, object message, Exception t);
>   void Warn(int eventId, object message);
>   void Warn(int eventId, object message, Exception t);
>   void Error(int eventId, object message);
>   void Error(int eventId, object message, Exception t);
>   void Fatal(int eventId, object message);
>   void Fatal(int eventId, object message, Exception t);
>  }
> 
> If so, there is example code here:
> 
> 
> http://cvs.apache.org/viewcvs.cgi/logging-log4net/extensions/net/1.0/
> 
> That works with both 1.0 and 1.1 of the Framework.
> 
> --- Billy Barnum <[EMAIL PROTECTED]> wrote:
> 
> > I'm logging with EventLogAppender, and setting the EventSource
> field
> > in the
> > Application Log using ApplicationName property. 
> > 
> > But I would like to log my own EventIds as well. Is there a way to
> do
> > this
> > with log4net? I'm not talking about putting something in the
> message
> > text,
> > but setting the actual eventID field in the log. I can't see a way.
> > What am
> > I missing?
> > 
> > 
> > WILLIAM BARNUM
> > [EMAIL PROTECTED]
> >  
> > 
> > 
> > 
> 
> 

Reply via email to