001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017 package org.apache.log4j.spi; 018 019 import java.util.Enumeration; 020 021 import org.apache.log4j.Appender; 022 import org.apache.log4j.Category; 023 import org.apache.log4j.Level; 024 import org.apache.log4j.Logger; 025 026 /** 027 * A <code>LoggerRepository</code> is used to create and retrieve 028 * <code>Loggers</code>. The relation between loggers in a repository 029 * depends on the repository but typically loggers are arranged in a 030 * named hierarchy. 031 * <p/> 032 * <p>In addition to the creational methods, a 033 * <code>LoggerRepository</code> can be queried for existing loggers, 034 * can act as a point of registry for events related to loggers. 035 * 036 * @since 1.2 037 */ 038 public interface LoggerRepository { 039 040 /** 041 * Add a {@link HierarchyEventListener} event to the repository. 042 * 043 * @param listener The listener 044 */ 045 void addHierarchyEventListener(HierarchyEventListener listener); 046 047 /** 048 * Returns whether this repository is disabled for a given 049 * level. The answer depends on the repository threshold and the 050 * <code>level</code> parameter. See also {@link #setThreshold} 051 * method. 052 * 053 * @param level The level 054 * @return whether this repository is disabled. 055 */ 056 boolean isDisabled(int level); 057 058 /** 059 * Set the repository-wide threshold. All logging requests below the 060 * threshold are immediately dropped. By default, the threshold is 061 * set to <code>Level.ALL</code> which has the lowest possible rank. 062 * 063 * @param level The level 064 */ 065 void setThreshold(Level level); 066 067 /** 068 * Another form of {@link #setThreshold(Level)} accepting a string 069 * parameter instead of a <code>Level</code>. 070 * 071 * @param val The threshold value 072 */ 073 void setThreshold(String val); 074 075 void emitNoAppenderWarning(Category cat); 076 077 /** 078 * Get the repository-wide threshold. See {@link #setThreshold(Level)} for an explanation. 079 * 080 * @return the level. 081 */ 082 Level getThreshold(); 083 084 Logger getLogger(String name); 085 086 Logger getLogger(String name, LoggerFactory factory); 087 088 Logger getRootLogger(); 089 090 Logger exists(String name); 091 092 void shutdown(); 093 094 @SuppressWarnings("rawtypes") 095 Enumeration getCurrentLoggers(); 096 097 /** 098 * Deprecated. Please use {@link #getCurrentLoggers} instead. 099 * 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 }