001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache license, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the license for the specific language governing permissions and
015 * limitations under the license.
016 */
017package org.apache.logging.log4j.core.jmx;
018
019
020/**
021 * The MBean interface for monitoring and managing an {@code Appender}.
022 */
023public interface AppenderAdminMBean {
024    /**
025     * ObjectName pattern ({@value}) for AppenderAdmin MBeans.
026     * This pattern contains two variables, where the first is the
027     * name of the context, the second is the name of the instrumented appender.
028     * <p>
029     * You can find all registered AppenderAdmin MBeans like this:
030     * </p>
031     * <pre>
032     * MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
033     * String pattern = String.format(AppenderAdminMBean.PATTERN, &quot;*&quot;, &quot;*&quot;);
034     * Set&lt;ObjectName&gt; appenderNames = mbs.queryNames(new ObjectName(pattern), null);
035     * </pre>
036     * <p>
037     * Some characters are not allowed in ObjectNames. The logger context name
038     * and appender name may be quoted. When AppenderAdmin MBeans are
039     * registered, their ObjectNames are created using this pattern as follows:
040     * </p>
041     * <pre>
042     * String ctxName = Server.escape(loggerContext.getName());
043     * String appenderName = Server.escape(appender.getName());
044     * String name = String.format(PATTERN, ctxName, appenderName);
045     * ObjectName objectName = new ObjectName(name);
046     * </pre>
047     * @see Server#escape(String)
048     */
049    String PATTERN = Server.DOMAIN + ":type=%s,component=Appenders,name=%s";
050
051    /**
052     * Returns the name of the instrumented {@code Appender}.
053     *
054     * @return the name of the Appender
055     */
056    String getName();
057
058    /**
059     * Returns the result of calling {@code toString} on the {@code Layout}
060     * object of the instrumented {@code Appender}.
061     *
062     * @return the {@code Layout} of the instrumented {@code Appender} as a
063     *         string
064     */
065    String getLayout();
066
067    /**
068     * Returns how exceptions thrown on the instrumented {@code Appender} are
069     * handled.
070     *
071     * @return {@code true} if any exceptions thrown by the Appender will be
072     *         logged or {@code false} if such exceptions are re-thrown.
073     */
074    boolean isIgnoreExceptions();
075
076    /**
077     * Returns the result of calling {@code toString} on the error handler of
078     * this appender, or {@code "null"} if no error handler was set.
079     *
080     * @return result of calling {@code toString} on the error handler of this
081     *         appender, or {@code "null"}
082     */
083    String getErrorHandler();
084
085    /**
086     * Returns a string description of all filters configured for the
087     * instrumented {@code Appender}.
088     *
089     * @return a string description of all configured filters for this
090     *         appender
091     */
092    String getFilter();
093}