View Javadoc
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.spi;
18  
19  import org.apache.log4j.*;
20  
21  import java.util.Enumeration;
22  
23  /**
24   * A <code>LoggerRepository</code> is used to create and retrieve
25   * <code>Loggers</code>. The relation between loggers in a repository
26   * depends on the repository but typically loggers are arranged in a
27   * named hierarchy.
28   * 
29   * <p>In addition to the creational methods, a
30   * <code>LoggerRepository</code> can be queried for existing loggers,
31   * can act as a point of registry for events related to loggers.
32   *
33   * @author Ceki G&uuml;lc&uuml;
34   * @since 1.2
35   */
36  public interface LoggerRepository {
37  
38      /**
39       * Add a {@link HierarchyEventListener} event to the repository.
40       * 
41       * @param listener a listener
42       */
43      public void addHierarchyEventListener(HierarchyEventListener listener);
44  
45      /**
46       * Returns whether this repository is disabled for a given
47       * level. The answer depends on the repository threshold and the
48       * <code>level</code> parameter. See also {@link #setThreshold}
49       * method.
50       */
51      boolean isDisabled(int level);
52  
53      /**
54       * Set the repository-wide threshold. All logging requests below the
55       * threshold are immediately dropped. By default, the threshold is
56       * set to <code>Level.ALL</code> which has the lowest possible rank.
57       */
58      public void setThreshold(Level level);
59  
60      /**
61       * Another form of {@link #setThreshold(Level)} accepting a string
62       * parameter instead of a <code>Level</code>.
63       */
64      public void setThreshold(String val);
65  
66      public void emitNoAppenderWarning(Category cat);
67  
68      /**
69       * Get the repository-wide threshold. See {@link
70       * #setThreshold(Level)} for an explanation.
71       */
72      public Level getThreshold();
73  
74      public Logger getLogger(String name);
75  
76      public Logger getLogger(String name, LoggerFactory factory);
77  
78      public Logger getRootLogger();
79  
80      public abstract Logger exists(String name);
81  
82      public abstract void shutdown();
83  
84      @SuppressWarnings("rawtypes")
85      public Enumeration getCurrentLoggers();
86  
87      /**
88       * Deprecated. Please use {@link #getCurrentLoggers} instead.
89       */
90      @SuppressWarnings("rawtypes")
91      public Enumeration getCurrentCategories();
92  
93      public abstract void fireAddAppenderEvent(Category logger, Appender appender);
94  
95      public abstract void resetConfiguration();
96  
97  }