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.jmx;
18  
19  import java.util.List;
20  
21  import org.apache.logging.log4j.status.StatusData;
22  
23  /**
24   * The MBean interface for monitoring and managing the {@code StatusLogger}.
25   */
26  public interface StatusLoggerAdminMBean {
27      /** Object name of this MBean. */
28      String NAME = "org.apache.logging.log4j2:type=StatusLogger";
29  
30      /**
31       * Notifications with this type have a {@code StatusData} userData object
32       * and a {@code null} message.
33       */
34      String NOTIF_TYPE_DATA = "com.apache.logging.log4j.core.jmx.statuslogger.data";
35  
36      /**
37       * Notifications with this type have a formatted status data message string
38       * but no {@code StatusData} in their userData field.
39       */
40      String NOTIF_TYPE_MESSAGE = "com.apache.logging.log4j.core.jmx.statuslogger.message";
41  
42      /**
43       * Returns a list with the most recent {@code StatusData} objects in the
44       * status history. The list has up to 200 entries by default but the length
45       * can be configured with system property {@code "log4j2.status.entries"}.
46       * <p>
47       * Note that the returned objects may contain {@code Throwable}s from
48       * external libraries.
49       * 
50       * JMX clients calling this method must be prepared to deal with the errors
51       * that occur if they do not have the class definition for such
52       * {@code Throwable}s in their classpath.
53       * 
54       * @return the most recent messages logged by the {@code StatusLogger}.
55       */
56      List<StatusData> getStatusData();
57  
58      /**
59       * Returns a string array with the most recent messages in the status
60       * history. The list has up to 200 entries by default but the length can be
61       * configured with system property {@code "log4j2.status.entries"}.
62       * 
63       * @return the most recent messages logged by the {@code StatusLogger}.
64       */
65      String[] getStatusDataHistory();
66  
67      /**
68       * Returns the {@code StatusLogger} level as a String.
69       * 
70       * @return the {@code StatusLogger} level.
71       */
72      String getLevel();
73  
74      /**
75       * Sets the {@code StatusLogger} level to the specified value.
76       * 
77       * @param level the new {@code StatusLogger} level.
78       * @throws IllegalArgumentException if the specified level is not one of
79       *             "OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE",
80       *             "ALL"
81       */
82      void setLevel(String level);
83  
84  }