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.activemq.broker.jmx;
018
019import java.util.List;
020
021/**
022 * Log4J Configuration Management MBean used to alter the runtime log levels
023 * or force a reload of the Log4J configuration file.
024 */
025public interface Log4JConfigViewMBean {
026
027    /**
028     * Get the log level for the root logger
029     *
030     * @returns the current log level of the root logger.
031     *
032     * @throws Exception if an error occurs while getting the root level.
033     */
034    @MBeanInfo("Returns the current logging level of the root logger.")
035    String getRootLogLevel() throws Exception;
036
037    /**
038     * Get the log level for the root logger
039     *
040     * @param level
041     *        the new level to assign to the root logger.
042     *
043     * @throws Exception if an error occurs while setting the root level.
044     */
045    @MBeanInfo("Sets the current logging level of the root logger.")
046    void setRootLogLevel(String level) throws Exception;
047
048    /**
049     * list of all the logger names and their levels
050     *
051     * @returns a List of all known loggers names.
052     *
053     * @throws Exception if an error occurs while getting the loggers.
054     */
055    @MBeanInfo("List of all loggers that are available for configuration.")
056    List<String> getLoggers() throws Exception;
057
058    /**
059     * Get the log level for a given logger
060     *
061     * @param loggerName
062     *        the name of the logger whose level should be queried.
063     *
064     * @returns the current log level of the given logger.
065     *
066     * @throws Exception if an error occurs while getting the log level.
067     */
068    @MBeanInfo("Returns the current logging level of a named logger.")
069    String getLogLevel(String loggerName) throws Exception;
070
071    /**
072     * Set the log level for a given logger
073     *
074     * @param loggerName
075     *        the name of the logger whose level is to be adjusted.
076     * @param level
077     *        the new level to assign the given logger.
078     *
079     * @throws Exception if an error occurs while setting the log level.
080     */
081    @MBeanInfo("Sets the logging level for the named logger.")
082    void setLogLevel(String loggerName, String level) throws Exception;
083
084    /**
085     * Reloads log4j.properties from the classpath.
086     *
087     * @throws Exception if an error occurs trying to reload the config file.
088     */
089    @MBeanInfo(value="Reloads log4j.properties from the classpath.")
090    public void reloadLog4jProperties() throws Throwable;
091
092}