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 018package org.apache.log4j.spi; 019 020import java.util.Enumeration; 021 022import org.apache.log4j.Appender; 023import org.apache.log4j.Category; 024import org.apache.log4j.Level; 025import org.apache.log4j.Logger; 026 027/** 028 A <code>LoggerRepository</code> is used to create and retrieve 029 <code>Loggers</code>. The relation between loggers in a repository 030 depends on the repository but typically loggers are arranged in a 031 named hierarchy. 032 033 <p>In addition to the creational methods, a 034 <code>LoggerRepository</code> can be queried for existing loggers, 035 can act as a point of registry for events related to loggers. 036 037 @author Ceki Gülcü 038 @since 1.2 */ 039public interface LoggerRepository { 040 041 /** 042 Add a {@link HierarchyEventListener} event to the repository. 043 */ 044 public 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 boolean isDisabled(int level); 053 054 /** 055 Set the repository-wide threshold. All logging requests below the 056 threshold are immediately dropped. By default, the threshold is 057 set to <code>Level.ALL</code> which has the lowest possible rank. */ 058 public 059 void setThreshold(Level level); 060 061 /** 062 Another form of {@link #setThreshold(Level)} accepting a string 063 parameter instead of a <code>Level</code>. */ 064 public 065 void setThreshold(String val); 066 067 public 068 void emitNoAppenderWarning(Category cat); 069 070 /** 071 Get the repository-wide threshold. See {@link 072 #setThreshold(Level)} for an explanation. */ 073 public 074 Level getThreshold(); 075 076 public 077 Logger getLogger(String name); 078 079 public 080 Logger getLogger(String name, LoggerFactory factory); 081 082 public 083 Logger getRootLogger(); 084 085 public 086 abstract 087 Logger exists(String name); 088 089 public 090 abstract 091 void shutdown(); 092 093 public 094 Enumeration getCurrentLoggers(); 095 096 /** 097 Deprecated. Please use {@link #getCurrentLoggers} instead. */ 098 public 099 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}