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  /**
20   * The MBean interface for monitoring and managing an {@code AsyncAppender}.
21   */
22  public interface AsyncAppenderAdminMBean {
23      /**
24       * ObjectName pattern ({@value} ) for AsyncAppenderAdmin MBeans. This
25       * pattern contains two variables, where the first is the name of the
26       * context, the second is the name of the instrumented appender.
27       * <p>
28       * You can find all registered AsyncAppenderAdmin MBeans like this:
29       * </p>
30       * 
31       * <pre>
32       * MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
33       * String pattern = String.format(AsyncAppenderAdminMBean.PATTERN, &quot;*&quot;, &quot;*&quot;);
34       * Set&lt;ObjectName&gt; appenderNames = mbs.queryNames(new ObjectName(pattern), null);
35       * </pre>
36       * <p>
37       * Some characters are not allowed in ObjectNames. The logger context name
38       * and appender name may be quoted. When AsyncAppenderAdmin MBeans are
39       * registered, their ObjectNames are created using this pattern as follows:
40       * </p>
41       * 
42       * <pre>
43       * String ctxName = Server.escape(loggerContext.getName());
44       * String appenderName = Server.escape(appender.getName());
45       * String name = String.format(PATTERN, ctxName, appenderName);
46       * ObjectName objectName = new ObjectName(name);
47       * </pre>
48       * 
49       * @see Server#escape(String)
50       */
51      String PATTERN = Server.DOMAIN + ":type=%s,component=AsyncAppenders,name=%s";
52  
53      /**
54       * Returns the name of the instrumented {@code AsyncAppender}.
55       * 
56       * @return the name of the AsyncAppender
57       */
58      String getName();
59  
60      /**
61       * Returns the result of calling {@code toString} on the {@code Layout}
62       * object of the instrumented {@code AsyncAppender}.
63       * 
64       * @return the {@code Layout} of the instrumented {@code AsyncAppender} as a
65       *         string
66       */
67      String getLayout();
68  
69      /**
70       * Returns how exceptions thrown on the instrumented {@code AsyncAppender}
71       * are handled.
72       * 
73       * @return {@code true} if any exceptions thrown by the AsyncAppender will
74       *         be logged or {@code false} if such exceptions are re-thrown.
75       */
76      boolean isIgnoreExceptions();
77  
78      /**
79       * Returns the result of calling {@code toString} on the error handler of
80       * this appender, or {@code "null"} if no error handler was set.
81       * 
82       * @return result of calling {@code toString} on the error handler of this
83       *         appender, or {@code "null"}
84       */
85      String getErrorHandler();
86  
87      /**
88       * Returns a string description of all filters configured for the
89       * instrumented {@code AsyncAppender}.
90       * 
91       * @return a string description of all configured filters for this appender
92       */
93      String getFilter();
94  
95      /**
96       * Returns a String array with the appender refs configured for the
97       * instrumented {@code AsyncAppender}.
98       * 
99       * @return the appender refs for the instrumented {@code AsyncAppender}.
100      */
101     String[] getAppenderRefs();
102 
103     /**
104      * Returns {@code true} if this AsyncAppender will take a snapshot of the
105      * stack with every log event to determine the class and method where the
106      * logging call was made.
107      * 
108      * @return {@code true} if location is included with every event,
109      *         {@code false} otherwise
110      */
111     boolean isIncludeLocation();
112 
113     /**
114      * Returns {@code true} if this AsyncAppender will block when the queue is
115      * full, or {@code false} if events are dropped when the queue is full.
116      * 
117      * @return whether this AsyncAppender will block or drop events when the
118      *         queue is full.
119      */
120     boolean isBlocking();
121     
122     /**
123      * Returns the name of the appender that any errors are logged to or {@code null}.
124      * @return the name of the appender that any errors are logged to or {@code null}
125      */
126     String getErrorRef();
127     
128     int getQueueCapacity();
129     
130     int getQueueRemainingCapacity();
131 }