The only real difference is how many times you assign to this variable.  As
a static member, it is assigned only once.  If it is an instance member then
you have to assign it with every instance.

As far as log4j is concerned, only one instance of the Logger (Category)
object is created, no matter how many times you call Logger.getInstance().
So, if you make it an instance member, it will be getting assigned the same
object anyways.  In my code I use:

  private static final Logger logger = Logger.getInstance(classname);

Unless there is a reason you would be creating new instances of the Logger
object, I think static is the way to go.

my opinion,
-Mark

-----Original Message-----
From: Chris Lambert [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 26, 2002 4:28 PM
To: [EMAIL PROTECTED]
Subject: static vs instance member



what are people's opinions about making a category object static vs making 
it an instance member?  should it always be declared static, is it 
necessary to declare it static if its never called from a static context?

e.g.

   private Category cat;

vs

   private static Category cat;




---------- --------- -------- ------- ------ ----- ---- --- -- -
Christopher Lambert

Lawrence Livermore National Laboratory
7000 East Avenue   M/S L-493
Livermore, CA 94550

B 481, Rm 2231  -  (925) 423-4927  -  [EMAIL PROTECTED]


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to