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 */
017package org.apache.logging.log4j.core.config;
018
019import java.util.Map;
020
021import org.apache.logging.log4j.core.Appender;
022import org.apache.logging.log4j.core.Filter;
023import org.apache.logging.log4j.core.LogEvent;
024import org.apache.logging.log4j.core.Logger;
025import org.apache.logging.log4j.core.filter.Filterable;
026import org.apache.logging.log4j.core.lookup.StrSubstitutor;
027import org.apache.logging.log4j.core.net.Advertiser;
028
029/**
030 * Interface that must be implemented to create a configuration.
031 */
032public interface Configuration extends Filterable {
033
034    /** Key for storing the Context properties. */
035    String CONTEXT_PROPERTIES = "ContextProperties";
036
037    /**
038     * Returns the configuration name.
039     * @return the name of the configuration.
040     */
041    String getName();
042
043    /**
044     * Locates the appropriate LoggerConfig for a Logger name. This will remove tokens from the
045     * package name as necessary or return the root LoggerConfig if no other matches were found.
046     * @param name The Logger name.
047     * @return The located LoggerConfig.
048     */
049    LoggerConfig getLoggerConfig(String name);
050
051    /**
052     * Returns the Appender with the specified name.
053     * @param name The name of the Appender.
054     * @return the Appender with the specified name or null if the Appender cannot be located.
055     */
056    Appender getAppender(String name);
057
058    /**
059     * Returns a Map containing all the Appenders and their name.
060     * @return A Map containing each Appender's name and the Appender object.
061     */
062    Map<String, Appender> getAppenders();
063
064    void addAppender(final Appender appender);
065
066    Map<String, LoggerConfig> getLoggers();
067
068    void addLoggerAppender(Logger logger, Appender appender);
069
070    void addLoggerFilter(Logger logger, Filter filter);
071
072    void setLoggerAdditive(Logger logger, boolean additive);
073
074    void addLogger(final String name, final LoggerConfig loggerConfig);
075
076    void removeLogger(final String name);
077
078    Map<String, String> getProperties();
079
080    void addListener(ConfigurationListener listener);
081
082    void removeListener(ConfigurationListener listener);
083
084    StrSubstitutor getStrSubstitutor();
085
086    void createConfiguration(Node node, LogEvent event);
087
088    <T> T getComponent(String name);
089
090    void addComponent(String name, Object object);
091
092    void setConfigurationMonitor(ConfigurationMonitor monitor);
093
094    ConfigurationMonitor getConfigurationMonitor();
095
096    void setAdvertiser(Advertiser advertiser);
097
098    Advertiser getAdvertiser();
099
100    boolean isShutdownHookEnabled();
101    
102    /**
103     * Returns the source of this configuration.
104     * @return the source of this configuration
105     */
106    ConfigurationSource getConfigurationSource();
107}