1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.log4j.spi;
19
20 import java.util.Enumeration;
21
22 import org.apache.log4j.Appender;
23 import org.apache.log4j.Category;
24 import org.apache.log4j.Level;
25 import org.apache.log4j.Logger;
26
27 /**
28 A <code>LoggerRepository</code> is used to create and retrieve
29 <code>Loggers</code>. The relation between loggers in a repository
30 depends on the repository but typically loggers are arranged in a
31 named hierarchy.
32
33 <p>In addition to the creational methods, a
34 <code>LoggerRepository</code> can be queried for existing loggers,
35 can act as a point of registry for events related to loggers.
36
37 @author Ceki Gülcü
38 @since 1.2 */
39 public interface LoggerRepository {
40
41 /**
42 Add a {@link HierarchyEventListener} event to the repository.
43 */
44 public
45 void addHierarchyEventListener(HierarchyEventListener listener);
46
47 /**
48 Returns whether this repository is disabled for a given
49 level. The answer depends on the repository threshold and the
50 <code>level</code> parameter. See also {@link #setThreshold}
51 method. */
52 boolean isDisabled(int level);
53
54 /**
55 Set the repository-wide threshold. All logging requests below the
56 threshold are immediately dropped. By default, the threshold is
57 set to <code>Level.ALL</code> which has the lowest possible rank. */
58 public
59 void setThreshold(Level level);
60
61 /**
62 Another form of {@link #setThreshold(Level)} accepting a string
63 parameter instead of a <code>Level</code>. */
64 public
65 void setThreshold(String val);
66
67 public
68 void emitNoAppenderWarning(Category cat);
69
70 /**
71 Get the repository-wide threshold. See {@link
72 #setThreshold(Level)} for an explanation. */
73 public
74 Level getThreshold();
75
76 public
77 Logger getLogger(String name);
78
79 public
80 Logger getLogger(String name, LoggerFactory factory);
81
82 public
83 Logger getRootLogger();
84
85 public
86 abstract
87 Logger exists(String name);
88
89 public
90 abstract
91 void shutdown();
92
93 public
94 Enumeration getCurrentLoggers();
95
96 /**
97 Deprecated. Please use {@link #getCurrentLoggers} instead. */
98 public
99 Enumeration getCurrentCategories();
100
101
102 public
103 abstract
104 void fireAddAppenderEvent(Category logger, Appender appender);
105
106 public
107 abstract
108 void resetConfiguration();
109
110 }