    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 <code>Loggers</code>.
    028     * <p>
    029     * The relation between loggers in a repository depends on the repository but typically loggers are arranged in a named
    030     * hierarchy.
    031     * </p>
    032     * <p>
    033     * In addition to the creational methods, a <code>LoggerRepository</code> can be queried for existing loggers, can act
    034     * as a point of registry for events related to loggers.
    035     * </p>
    036     *
    037     * @since 1.2
    038     */
    039    public interface LoggerRepository {
    040
    041        /**
    042         * Add a {@link HierarchyEventListener} event to the repository.
    043         *
    044         * @param listener The listener
    045         */
    046        void addHierarchyEventListener(HierarchyEventListener listener);
    047
    048        /**
    049         * Returns whether this repository is disabled for a given
    050         * level. The answer depends on the repository threshold and the
    051         * <code>level</code> parameter. See also {@link #setThreshold}
    052         * method.
    053         *
    054         * @param level The level
    055         * @return whether this repository is disabled.
    056         */
    057        boolean isDisabled(int level);
    058
    059        /**
    060         * Set the repository-wide threshold. All logging requests below the
    061         * threshold are immediately dropped. By default, the threshold is
    062         * set to <code>Level.ALL</code> which has the lowest possible rank.
    063         *
    064         * @param level The level
    065         */
    066        void setThreshold(Level level);
    067
    068        /**
    069         * Another form of {@link #setThreshold(Level)} accepting a string
    070         * parameter instead of a <code>Level</code>.
    071         *
    072         * @param val The threshold value
    073         */
    074        void setThreshold(String val);
    075
    076        void emitNoAppenderWarning(Category cat);
    077
    078        /**
    079         * Get the repository-wide threshold. See {@link #setThreshold(Level)} for an explanation.
    080         *
    081         * @return the level.
    082         */
    083        Level getThreshold();
    084
    085        Logger getLogger(String name);
    086
    087        Logger getLogger(String name, LoggerFactory factory);
    088
    089        Logger getRootLogger();
    090
    091        Logger exists(String name);
    092
    093        void shutdown();
    094
    095        @SuppressWarnings("rawtypes")
    096        Enumeration getCurrentLoggers();
    097
    098        /**
    099         * Deprecated. Please use {@link #getCurrentLoggers} instead.
    100         *
    101         * @return an enumeration of loggers.
    102         */
    103        @SuppressWarnings("rawtypes")
    104        Enumeration getCurrentCategories();
    105
    106        void fireAddAppenderEvent(Category logger, Appender appender);
    107
    108        void resetConfiguration();
    109    }