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  
18  package org.apache.log4j.spi;
19  
20  import org.apache.log4j.Appender;
21  import org.apache.log4j.Logger;
22  
23  
24  /**
25   * Interface used to listen for Logger related events such as
26   * add/remove appender or changing levels.  Clients register an instance of
27   * the interface and the instance is called back when the various events occur.
28   * <p>
29   * LoggerRepository provides methods for adding and removing
30   * LoggerEventListener instances.
31   * <p>
32   * When implementing the methods of this interface, it is useful to remember
33   * that the Logger can access the repository using its getRepository()
34   * method.
35   *
36   * @author Ceki G&uuml;lc&uuml;
37   * @author Mark Womack
38   */
39  public interface LoggerEventListener {
40      /**
41       * Called when an appender is added to the logger.
42       *
43       * @param logger   The logger to which the appender was added.
44       * @param appender The appender added to the logger.
45       */
46      void appenderAddedEvent(Logger logger, Appender appender);
47  
48      /**
49       * Called when an appender is removed from the logger.
50       *
51       * @param logger   The logger from which the appender was removed.
52       * @param appender The appender removed from the logger.
53       */
54      void appenderRemovedEvent(Logger logger, Appender appender);
55  
56      /**
57       * Called when level changed on the logger.
58       *
59       * @param logger The logger that changed levels.
60       */
61      void levelChangedEvent(Logger logger);
62  }