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 * 
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     * @param listener a listener
042     */
043    public 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    public 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    public void setThreshold(String val);
065
066    public void emitNoAppenderWarning(Category cat);
067
068    /**
069     * Get the repository-wide threshold. See {@link
070     * #setThreshold(Level)} for an explanation.
071     */
072    public Level getThreshold();
073
074    public Logger getLogger(String name);
075
076    public Logger getLogger(String name, LoggerFactory factory);
077
078    public Logger getRootLogger();
079
080    public abstract Logger exists(String name);
081
082    public abstract void shutdown();
083
084    @SuppressWarnings("rawtypes")
085    public Enumeration getCurrentLoggers();
086
087    /**
088     * Deprecated. Please use {@link #getCurrentLoggers} instead.
089     */
090    @SuppressWarnings("rawtypes")
091    public Enumeration getCurrentCategories();
092
093    public abstract void fireAddAppenderEvent(Category logger, Appender appender);
094
095    public abstract void resetConfiguration();
096
097}