"You CANNOT use MyClass.class and have MySubClass.class show up in the log statements, since this is static.  You must use dynamic initialization."
 
That's why I duplicate the one line of code in each of my classes. It's true you could probably factor it out into a common superclass, but it just seems easier to me to replicate the _one_ line of code per class. That eliminates threading issues entirely.

 -----Original Message-----
From: Kevin Ross [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 19, 2002 2:30 PM
To: [EMAIL PROTECTED]
Subject: Re: LogFactory.getLogger()

Threading issues?? I knew someone would bring that up.  Thread safetyness is the responsibility, gladly accepted by a logger instance, not on the classes using it.  There is NO reason why we need paranoid checking here to only get one instance, since it is the responsibility of the logging implementation to even provide the instance in the first place.  Do you really think you'll get different instances?  Probably not, worst case scenario, you call Logger.getLogger() twice and initialize your instance twice in a race condition.  Since it is of zero consequence either way, there is no reason to do it differently.  If you are particularly worried, just do:

private transient Logger logger = LogFactory.getLogger(getClass());

You CANNOT use MyClass.class and have MySubClass.class show up in the log statements, since this is static.  You must use dynamic initialization.
 
-Kevin

Kevin A. Smith wrote:
 

Reply via email to