View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements. See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache license, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License. You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the license for the specific language governing permissions and
15   * limitations under the license.
16   */
17  package org.apache.logging.log4j.core.config;
18  
19  import java.util.Map;
20  
21  import org.apache.logging.log4j.core.Appender;
22  import org.apache.logging.log4j.core.Filter;
23  import org.apache.logging.log4j.core.LogEvent;
24  import org.apache.logging.log4j.core.Logger;
25  import org.apache.logging.log4j.core.filter.Filterable;
26  import org.apache.logging.log4j.core.lookup.StrSubstitutor;
27  import org.apache.logging.log4j.core.net.Advertiser;
28  
29  /**
30   * Interface that must be implemented to create a configuration.
31   */
32  public interface Configuration extends Filterable {
33  
34      /** Key for storing the Context properties. */
35      String CONTEXT_PROPERTIES = "ContextProperties";
36  
37      /**
38       * Returns the configuration name.
39       * @return the name of the configuration.
40       */
41      String getName();
42  
43      /**
44       * Locates the appropriate LoggerConfig for a Logger name. This will remove tokens from the
45       * package name as necessary or return the root LoggerConfig if no other matches were found.
46       * @param name The Logger name.
47       * @return The located LoggerConfig.
48       */
49      LoggerConfig getLoggerConfig(String name);
50  
51      /**
52       * Returns the Appender with the specified name.
53       * @param name The name of the Appender.
54       * @return the Appender with the specified name or null if the Appender cannot be located.
55       */
56      Appender getAppender(String name);
57  
58      /**
59       * Returns a Map containing all the Appenders and their name.
60       * @return A Map containing each Appender's name and the Appender object.
61       */
62      Map<String, Appender> getAppenders();
63  
64      void addAppender(final Appender appender);
65  
66      Map<String, LoggerConfig> getLoggers();
67  
68      void addLoggerAppender(Logger logger, Appender appender);
69  
70      void addLoggerFilter(Logger logger, Filter filter);
71  
72      void setLoggerAdditive(Logger logger, boolean additive);
73  
74      void addLogger(final String name, final LoggerConfig loggerConfig);
75  
76      void removeLogger(final String name);
77  
78      Map<String, String> getProperties();
79  
80      void addListener(ConfigurationListener listener);
81  
82      void removeListener(ConfigurationListener listener);
83  
84      StrSubstitutor getStrSubstitutor();
85  
86      void createConfiguration(Node node, LogEvent event);
87  
88      <T> T getComponent(String name);
89  
90      void addComponent(String name, Object object);
91  
92      void setConfigurationMonitor(ConfigurationMonitor monitor);
93  
94      ConfigurationMonitor getConfigurationMonitor();
95  
96      void setAdvertiser(Advertiser advertiser);
97  
98      Advertiser getAdvertiser();
99  
100     boolean isShutdownHookEnabled();
101     
102     /**
103      * Returns the source of this configuration.
104      * @return the source of this configuration
105      */
106     ConfigurationSource getConfigurationSource();
107 }