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