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 /**
21 * The MBean interface for monitoring and managing an {@code Appender}.
22 */
23 public interface AppenderAdminMBean {
24 /**
25 * ObjectName pattern ({@value}) for AppenderAdmin MBeans.
26 * This pattern contains two variables, where the first is the
27 * name of the context, the second is the name of the instrumented appender.
28 * <p>
29 * You can find all registered AppenderAdmin MBeans like this:
30 * </p>
31 * <pre>
32 * MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
33 * String pattern = String.format(AppenderAdminMBean.PATTERN, "*", "*");
34 * Set<ObjectName> 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 AppenderAdmin MBeans are
39 * registered, their ObjectNames are created using this pattern as follows:
40 * </p>
41 * <pre>
42 * String ctxName = Server.escape(loggerContext.getName());
43 * String appenderName = Server.escape(appender.getName());
44 * String name = String.format(PATTERN, ctxName, appenderName);
45 * ObjectName objectName = new ObjectName(name);
46 * </pre>
47 * @see Server#escape(String)
48 */
49 String PATTERN = Server.DOMAIN + ":type=%s,component=Appenders,name=%s";
50
51 /**
52 * Returns the name of the instrumented {@code Appender}.
53 *
54 * @return the name of the Appender
55 */
56 String getName();
57
58 /**
59 * Returns the result of calling {@code toString} on the {@code Layout}
60 * object of the instrumented {@code Appender}.
61 *
62 * @return the {@code Layout} of the instrumented {@code Appender} as a
63 * string
64 */
65 String getLayout();
66
67 /**
68 * Returns how exceptions thrown on the instrumented {@code Appender} are
69 * handled.
70 *
71 * @return {@code true} if any exceptions thrown by the Appender will be
72 * logged or {@code false} if such exceptions are re-thrown.
73 */
74 boolean isIgnoreExceptions();
75
76 /**
77 * Returns the result of calling {@code toString} on the error handler of
78 * this appender, or {@code "null"} if no error handler was set.
79 *
80 * @return result of calling {@code toString} on the error handler of this
81 * appender, or {@code "null"}
82 */
83 String getErrorHandler();
84
85 /**
86 * Returns a string description of all filters configured for the
87 * instrumented {@code Appender}.
88 *
89 * @return a string description of all configured filters for this
90 * appender
91 */
92 String getFilter();
93 }