great, thanks!

i think i can keep the logger-object static and just pass the 
"memberCount"-value with the log-message itself. this should save some memory 
when i have a lot of instances, right?

... i had hoped that there is something "builtin" (dotnet or log4net) which i'm 
not aware of ...

thanks again
franz

-----Ursprüngliche Nachricht-----
Von: Göran Roseen [mailto:[EMAIL PROTECTED] 
Gesendet: Freitag, 04. November 2005 10:28
An: 'Log4NET User'
Betreff: RE: different object instances


The really simple solution is to name the loggers when you create them,
i.e.:

public class myClass
{
        private ILog loginst;
        private static int memberCount = 0;

        public myClass()
        {
                loginst = LogManager.GetLogger("myClass." +
memberCount++.ToString());
        }
}

Note that the logger no longer can be static.
The counter to keep track of instances could of course be replaced with 
something more sophisticated, as should the naming of the logger.

/Göran

-----Original Message-----
From: Strele Franz [mailto:[EMAIL PROTECTED]
Sent: den 4 november 2005 09:48
To: Log4NET User
Subject: different object instances

hi all,

is it possible to distinguish different instances of a class (written in
c#) in the log-output?

in the old vb6 days, i could use the "ObjPtr"-function to get a "unique value" 
for each instance. in c# i could use the "GetHashCode"-function, but the docs 
say i'm not supposed to use it for that. how can i do that without adding 
specific code to the class myself? all i want to see is which log-entry comes 
from which instance...

thanks
franz





Reply via email to