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