You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Xinjian Xue <xi...@peregrine.com> on 2002/06/01 00:22:59 UTC

RE: Bug in getLogger(String, LoggerFactory)?

Jon,
I have the same problem as you reported. Have you got some answer or some
solutions? 
Thanks.
 

------------------------------------------------------------- 
Xinjian Jack Xue, Phone: 317 554 7622 

-----Original Message-----
From: Jon Wilmoth [mailto:JWilmoth@starbucks.com]
Sent: Wednesday, May 29, 2002 10:03 AM
To: log4j-dev@jakarta.apache.org
Cc: log4j-user@jakarta.apache.org
Subject: Bug in getLogger(String, LoggerFactory)?



I'm using a custom LoggerFactory and not getting the expected behavior.
After taking a look at the source, the Hiearchy class's implementation of
getLogger(String, LoggerFactory) doesn't account for the LoggerFactory
producing logger's with different names.  The CategoryKey used to cache is
always the name of the string param and not the LoggerName.  Is this a bug?
I've attached a unit test which illustrate the problem.

 

Logger getLogger(String name, LoggerFactory factory) {

    //System.out.println("getInstance("+name+") called.");

    CategoryKey key = new CategoryKey(name);    

    // Synchronize to prevent write conflicts. Read conflicts (in

    // getChainedLevel method) are possible only if variable

    // assignments are non-atomic.

    Logger logger;

    

    synchronized(ht) {

      Object o = ht.get(key);

      if(o == null) {

            logger = factory.makeNewLoggerInstance(name);

...

}

 

Jon Wilmoth

Technical Specialist

Starbucks Coffee Company