001 /*
002 * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package java.util.logging;
027
028 /**
029 * The management interface for the logging facility.
030 *
031 * <p>There is a single global instance of the <tt>LoggingMXBean</tt>.
032 * This instance is an
033 * <a href="../../lang/management/ManagementFactory.html#MXBean">MXBean</a>
034 * can be obtained by calling
035 * the {@link LogManager#getLoggingMXBean} method or from the
036 * {@link java.lang.management.ManagementFactory#getPlatformMBeanServer
037 * platform <tt>MBeanServer</tt>} method.
038 *
039 * <p>The {@link javax.management.ObjectName ObjectName} for uniquely
040 * identifying the <tt>LoggingMXBean</tt> within an MBeanServer is:
041 * <blockquote>
042 * {@link LogManager#LOGGING_MXBEAN_NAME
043 * <tt>java.util.logging:type=Logging</tt>}
044 * </blockquote>
045 *
046 * @see java.lang.management.ManagementFactory
047 *
048 * @author Ron Mann
049 * @author Mandy Chung
050 * @version 1.15, 05/05/07
051 * @since 1.5
052 *
053 */
054 public interface LoggingMXBean {
055
056 /**
057 * Returns the list of currently registered loggers. This method
058 * calls {@link LogManager#getLoggerNames} and returns a list
059 * of the logger names.
060 *
061 * @return A list of <tt>String</tt> each of which is a
062 * currently registered <tt>Logger</tt> name.
063 */
064 public java.util.List<String> getLoggerNames();
065
066 /**
067 * Gets the name of the log level associated with the specified logger.
068 * If the specified logger does not exist, <tt>null</tt>
069 * is returned.
070 * This method first finds the logger of the given name and
071 * then returns the name of the log level by calling:
072 * <blockquote>
073 * {@link Logger#getLevel Logger.getLevel()}.{@link Level#getName getName()};
074 * </blockquote>
075 *
076 * <p>
077 * If the <tt>Level</tt> of the specified logger is <tt>null</tt>,
078 * which means that this logger's effective level is inherited
079 * from its parent, an empty string will be returned.
080 *
081 * @param loggerName The name of the <tt>Logger</tt> to be retrieved.
082 *
083 * @return The name of the log level of the specified logger; or
084 * an empty string if the log level of the specified logger
085 * is <tt>null</tt>. If the specified logger does not
086 * exist, <tt>null</tt> is returned.
087 *
088 * @see Logger#getLevel
089 */
090 public String getLoggerLevel(String loggerName);
091
092 /**
093 * Sets the specified logger to the specified new level.
094 * If the <tt>levelName</tt> is not <tt>null</tt>, the level
095 * of the specified logger is set to the parsed <tt>Level</tt>
096 * matching the <tt>levelName</tt>.
097 * If the <tt>levelName</tt> is <tt>null</tt>, the level
098 * of the specified logger is set to <tt>null</tt> and
099 * the effective level of the logger is inherited from
100 * its nearest ancestor with a specific (non-null) level value.
101 *
102 * @param loggerName The name of the <tt>Logger</tt> to be set.
103 * Must be non-null.
104 * @param levelName The name of the level to set the specified logger to,
105 * or <tt>null</tt> if to set the level to inherit
106 * from its nearest ancestor.
107 *
108 * @throws IllegalArgumentException if the specified logger
109 * does not exist, or <tt>levelName</tt> is not a valid level name.
110 *
111 * @throws SecurityException if a security manager exists and if
112 * the caller does not have LoggingPermission("control").
113 *
114 * @see Logger#setLevel
115 */
116 public void setLoggerLevel(String loggerName, String levelName);
117
118 /**
119 * Returns the name of the parent for the specified logger.
120 * If the specified logger does not exist, <tt>null</tt> is returned.
121 * If the specified logger is the root <tt>Logger</tt> in the namespace,
122 * the result will be an empty string.
123 *
124 * @param loggerName The name of a <tt>Logger</tt>.
125 *
126 * @return the name of the nearest existing parent logger;
127 * an empty string if the specified logger is the root logger.
128 * If the specified logger does not exist, <tt>null</tt>
129 * is returned.
130 */
131 public String getParentLoggerName(String loggerName);
132 }
|