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