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 org.apache.log4j.Appender;
020    import org.apache.log4j.Category;
021    import org.apache.log4j.Level;
022    import org.apache.log4j.Logger;
023    
024    import java.util.Enumeration;
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        void addHierarchyEventListener(HierarchyEventListener listener);
044    
045        /**
046         * Returns whether this repository is disabled for a given
047         * level. The answer depends on the repository threshold and the
048         * <code>level</code> parameter. See also {@link #setThreshold}
049         * method.
050         */
051        boolean isDisabled(int level);
052    
053        /**
054         * Set the repository-wide threshold. All logging requests below the
055         * threshold are immediately dropped. By default, the threshold is
056         * set to <code>Level.ALL</code> which has the lowest possible rank.
057         */
058        void setThreshold(Level level);
059    
060        /**
061         * Another form of {@link #setThreshold(Level)} accepting a string
062         * parameter instead of a <code>Level</code>.
063         */
064        void setThreshold(String val);
065    
066        void emitNoAppenderWarning(Category cat);
067    
068        /**
069         * Get the repository-wide threshold. See {@link
070         * #setThreshold(Level)} for an explanation.
071         */
072        Level getThreshold();
073    
074        Logger getLogger(String name);
075    
076        Logger getLogger(String name, LoggerFactory factory);
077    
078        Logger getRootLogger();
079    
080        abstract Logger exists(String name);
081    
082        abstract void shutdown();
083    
084        Enumeration getCurrentLoggers();
085    
086        /**
087         * Deprecated. Please use {@link #getCurrentLoggers} instead.
088         */
089        Enumeration getCurrentCategories();
090    
091    
092        abstract void fireAddAppenderEvent(Category logger, Appender appender);
093    
094        abstract void resetConfiguration();
095    
096    }