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 * <p/> 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ülcü 34 * @since 1.2 35 */ 36 public interface LoggerRepository { 37 38 /** 39 * Add a {@link HierarchyEventListener} event to the repository. 40 */ addHierarchyEventListener(HierarchyEventListener listener)41 public void addHierarchyEventListener(HierarchyEventListener listener); 42 43 /** 44 * Returns whether this repository is disabled for a given 45 * level. The answer depends on the repository threshold and the 46 * <code>level</code> parameter. See also {@link #setThreshold} 47 * method. 48 */ isDisabled(int level)49 boolean isDisabled(int level); 50 51 /** 52 * Set the repository-wide threshold. All logging requests below the 53 * threshold are immediately dropped. By default, the threshold is 54 * set to <code>Level.ALL</code> which has the lowest possible rank. 55 */ setThreshold(Level level)56 public void setThreshold(Level level); 57 58 /** 59 * Another form of {@link #setThreshold(Level)} accepting a string 60 * parameter instead of a <code>Level</code>. 61 */ setThreshold(String val)62 public void setThreshold(String val); 63 emitNoAppenderWarning(Category cat)64 public void emitNoAppenderWarning(Category cat); 65 66 /** 67 * Get the repository-wide threshold. See {@link 68 * #setThreshold(Level)} for an explanation. 69 */ getThreshold()70 public Level getThreshold(); 71 getLogger(String name)72 public Logger getLogger(String name); 73 getLogger(String name, LoggerFactory factory)74 public Logger getLogger(String name, LoggerFactory factory); 75 getRootLogger()76 public Logger getRootLogger(); 77 exists(String name)78 public abstract Logger exists(String name); 79 shutdown()80 public abstract void shutdown(); 81 82 @SuppressWarnings("rawtypes") getCurrentLoggers()83 public Enumeration getCurrentLoggers(); 84 85 /** 86 * Deprecated. Please use {@link #getCurrentLoggers} instead. 87 */ 88 @SuppressWarnings("rawtypes") getCurrentCategories()89 public Enumeration getCurrentCategories(); 90 fireAddAppenderEvent(Category logger, Appender appender)91 public abstract void fireAddAppenderEvent(Category logger, Appender appender); 92 resetConfiguration()93 public abstract void resetConfiguration(); 94 95 } 96