logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From José Joye <jose.j...@bluewin.ch>
Subject Re: What is the best way to attach an ID with each logged message?
Date Sat, 20 Jan 2007 21:09:22 GMT
Thanks Ron,

In fact, I do not want to have unicity between messages. The idea is, 
whenever we log a message,  to give the possibility to also attach an 
identifyer (eg: BadParameter, CommunicationProblem) which correspond to 
integer number. This will allow us to filter such information.
If a message is log without identifyer, a default one will be used (1 for 
debug, 1 for info, ...).

This means that the same ID could be attached to messages issued from 
different places in the code.

I will have a look to the eventID.


- José

----- Original Message ----- 
From: "Ron Grabowski" <rongrabowski@yahoo.com>
To: "Log4NET User" <log4net-user@logging.apache.org>
Sent: Saturday, January 20, 2007 8:00 PM
Subject: Re: What is the best way to attach an ID with each logged message?

ILogger.Log has two overloads. You need to create a LoggingEvent and use the 
Log overload that accepts a LoggingEvent. Once you've created a LoggingEvent 
object you can store additional information in Properties:

LoggingEvent loggingEvent = new LoggingEvent(

loggingEvent.Properties["GUID"] = Guid.NewGuid();


The log4net.Ext.EventID folder contains a more complete example:


Creating Guids for every message may be too expensive. Do log event ids have 
to be unique across all instances of application or just the current 
instance? Interlocked.Increment can be used as a global counter:


If you write to a database you could use the logging table's primary key as 
a unique identifier. Chainsaw can be configured to automatically query a 
database every N seconds.

----- Original Message ----
From: José Joye <jose.joye@bluewin.ch>
To: Log4NET User <log4net-user@logging.apache.org>
Sent: Saturday, January 20, 2007 4:42:17 AM
Subject: What is the best way to attach  an ID with each logged message?


I'm looking for a possibility of attaching an ID to each information logged
using Log4Net. What will be the best way to use in order to be compatible
with with existing viewers (chainsaw, ...).

Basically, I want to expose such an overloaded method in my Logger façade:

void Info(int id, string msg);

and I would like to have this information displayed/available in existing
viewer and appenders.


- José

View raw message