Source code

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