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     */
017    package org.apache.logging.log4j.core.jmx;
018    
019    import java.util.List;
020    
021    import org.apache.logging.log4j.status.StatusData;
022    
023    /**
024     * The MBean interface for monitoring and managing the {@code StatusLogger}.
025     */
026    public interface StatusLoggerAdminMBean {
027        /** Object name ({@value}) of this MBean. */
028        String NAME = "org.apache.logging.log4j2:type=StatusLogger";
029    
030        /**
031         * Notifications with this type have a {@code StatusData} userData object
032         * and a {@code null} message.
033         */
034        String NOTIF_TYPE_DATA = "com.apache.logging.log4j.core.jmx.statuslogger.data";
035    
036        /**
037         * Notifications with this type have a formatted status data message string
038         * but no {@code StatusData} in their userData field.
039         */
040        String NOTIF_TYPE_MESSAGE = "com.apache.logging.log4j.core.jmx.statuslogger.message";
041    
042        /**
043         * Returns a list with the most recent {@code StatusData} objects in the
044         * status history. The list has up to 200 entries by default but the length
045         * can be configured with system property {@code "log4j2.status.entries"}.
046         * <p>
047         * Note that the returned objects may contain {@code Throwable}s from
048         * external libraries.
049         * 
050         * JMX clients calling this method must be prepared to deal with the errors
051         * that occur if they do not have the class definition for such
052         * {@code Throwable}s in their classpath.
053         * 
054         * @return the most recent messages logged by the {@code StatusLogger}.
055         */
056        List<StatusData> getStatusData();
057    
058        /**
059         * Returns a string array with the most recent messages in the status
060         * history. The list has up to 200 entries by default but the length can be
061         * configured with system property {@code "log4j2.status.entries"}.
062         * 
063         * @return the most recent messages logged by the {@code StatusLogger}.
064         */
065        String[] getStatusDataHistory();
066    
067        /**
068         * Returns the {@code StatusLogger} level as a String.
069         * 
070         * @return the {@code StatusLogger} level.
071         */
072        String getLevel();
073    
074        /**
075         * Sets the {@code StatusLogger} level to the specified value.
076         * 
077         * @param level the new {@code StatusLogger} level.
078         * @throws IllegalArgumentException if the specified level is not one of
079         *             "OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE",
080         *             "ALL"
081         */
082        void setLevel(String level);
083    
084    }