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 org.apache.logging.log4j.core.Appender;
20  import org.apache.logging.log4j.core.Filter;
21  import org.apache.logging.log4j.core.LogEvent;
22  import org.apache.logging.log4j.core.Logger;
23  import org.apache.logging.log4j.core.filter.Filterable;
24  import org.apache.logging.log4j.core.lookup.StrSubstitutor;
25  
26  import java.util.Map;
27  
28  /**
29   * Interface that must be implemented to create a configuration.
30   */
31  public interface Configuration extends Filterable {
32  
33      /** Key for storing the Context properties. */
34      String CONTEXT_PROPERTIES = "ContextProperties";
35  
36      /**
37       * Returns the configuration name.
38       * @return the name of the configuration.
39       */
40      String getName();
41  
42      /**
43       * Locates the appropriate LoggerConfig for a Logger name. This will remove tokens from the
44       * package name as necessary or return the root LoggerConfig if no other matches were found.
45       * @param name The Logger name.
46       * @return The located LoggerConfig.
47       */
48      LoggerConfig getLoggerConfig(String name);
49  
50      /**
51       * Returns a Map containing all the Appenders and their name.
52       * @return A Map containing each Appender's name and the Appender object.
53       */
54      Map<String, Appender<?>> getAppenders();
55  
56      Map<String, LoggerConfig> getLoggers();
57  
58      void addLoggerAppender(Logger logger, Appender<?> appender);
59  
60      void addLoggerFilter(Logger logger, Filter filter);
61  
62      void setLoggerAdditive(Logger logger, boolean additive);
63  
64      Map<String, String> getProperties();
65  
66      void start();
67  
68      void stop();
69  
70      void addListener(ConfigurationListener listener);
71  
72      void removeListener(ConfigurationListener listener);
73  
74      StrSubstitutor getSubst();
75  
76      void createConfiguration(Node node, LogEvent event);
77  
78      Object getComponent(String name);
79  
80      void addComponent(String name, Object object);
81  
82      ConfigurationMonitor getConfigurationMonitor();
83  }