1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.log4j;
18  
19  import java.util.Hashtable;
20  
21  /**
22   * This class is a factory that creates and maintains org.apache.log4j.Loggers
23   * warpping org.slf4j.Loggers.
24   * 
25   * It keeps a hashtable of all created org.apache.log4j.Logger instances so that
26   * all newly created instances are not dulpicates of existing loggers.
27   * 
28   * @author Sébastien Pennec
29   */
30  class Log4jLoggerFactory {
31  
32    // String, Logger
33    private static Hashtable log4jLoggers = new Hashtable();
34  
35    public static synchronized Logger getLogger(String name) {
36      if (log4jLoggers.containsKey(name)) {
37        return (org.apache.log4j.Logger) log4jLoggers.get(name);
38      } else {
39        Logger log4jLogger = new Logger(name);
40        
41        log4jLoggers.put(name, log4jLogger);
42        return log4jLogger;
43      }
44    }
45  
46  }