J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | package java.util.logging; |
| 27 | |
| 28 | /** |
| 29 | * The management interface for the logging facility. |
| 30 | * |
| 31 | * <p>There is a single global instance of the <tt>LoggingMXBean</tt>. |
| 32 | * This instance is an |
| 33 | * <a href="../../lang/management/ManagementFactory.html#MXBean">MXBean</a> |
| 34 | * can be obtained by calling |
| 35 | * the {@link LogManager#getLoggingMXBean} method or from the |
| 36 | * {@link java.lang.management.ManagementFactory#getPlatformMBeanServer |
| 37 | * platform <tt>MBeanServer</tt>} method. |
| 38 | * |
| 39 | * <p>The {@link javax.management.ObjectName ObjectName} for uniquely |
| 40 | * identifying the <tt>LoggingMXBean</tt> within an MBeanServer is: |
| 41 | * <blockquote> |
| 42 | * {@link LogManager#LOGGING_MXBEAN_NAME |
| 43 | * <tt>java.util.logging:type=Logging</tt>} |
| 44 | * </blockquote> |
| 45 | * |
| 46 | * @see java.lang.management.ManagementFactory |
| 47 | * |
| 48 | * @author Ron Mann |
| 49 | * @author Mandy Chung |
| 50 | * @since 1.5 |
| 51 | * |
| 52 | */ |
| 53 | public interface LoggingMXBean { |
| 54 | |
| 55 | /** |
| 56 | * Returns the list of currently registered loggers. This method |
| 57 | * calls {@link LogManager#getLoggerNames} and returns a list |
| 58 | * of the logger names. |
| 59 | * |
| 60 | * @return A list of <tt>String</tt> each of which is a |
| 61 | * currently registered <tt>Logger</tt> name. |
| 62 | */ |
| 63 | public java.util.List<String> getLoggerNames(); |
| 64 | |
| 65 | /** |
| 66 | * Gets the name of the log level associated with the specified logger. |
| 67 | * If the specified logger does not exist, <tt>null</tt> |
| 68 | * is returned. |
| 69 | * This method first finds the logger of the given name and |
| 70 | * then returns the name of the log level by calling: |
| 71 | * <blockquote> |
| 72 | * {@link Logger#getLevel Logger.getLevel()}.{@link Level#getName getName()}; |
| 73 | * </blockquote> |
| 74 | * |
| 75 | * <p> |
| 76 | * If the <tt>Level</tt> of the specified logger is <tt>null</tt>, |
| 77 | * which means that this logger's effective level is inherited |
| 78 | * from its parent, an empty string will be returned. |
| 79 | * |
| 80 | * @param loggerName The name of the <tt>Logger</tt> to be retrieved. |
| 81 | * |
| 82 | * @return The name of the log level of the specified logger; or |
| 83 | * an empty string if the log level of the specified logger |
| 84 | * is <tt>null</tt>. If the specified logger does not |
| 85 | * exist, <tt>null</tt> is returned. |
| 86 | * |
| 87 | * @see Logger#getLevel |
| 88 | */ |
| 89 | public String getLoggerLevel( String loggerName ); |
| 90 | |
| 91 | /** |
| 92 | * Sets the specified logger to the specified new level. |
| 93 | * If the <tt>levelName</tt> is not <tt>null</tt>, the level |
| 94 | * of the specified logger is set to the parsed <tt>Level</tt> |
| 95 | * matching the <tt>levelName</tt>. |
| 96 | * If the <tt>levelName</tt> is <tt>null</tt>, the level |
| 97 | * of the specified logger is set to <tt>null</tt> and |
| 98 | * the effective level of the logger is inherited from |
| 99 | * its nearest ancestor with a specific (non-null) level value. |
| 100 | * |
| 101 | * @param loggerName The name of the <tt>Logger</tt> to be set. |
| 102 | * Must be non-null. |
| 103 | * @param levelName The name of the level to set the specified logger to, |
| 104 | * or <tt>null</tt> if to set the level to inherit |
| 105 | * from its nearest ancestor. |
| 106 | * |
| 107 | * @throws IllegalArgumentException if the specified logger |
| 108 | * does not exist, or <tt>levelName</tt> is not a valid level name. |
| 109 | * |
| 110 | * @throws SecurityException if a security manager exists and if |
| 111 | * the caller does not have LoggingPermission("control"). |
| 112 | * |
| 113 | * @see Logger#setLevel |
| 114 | */ |
| 115 | public void setLoggerLevel( String loggerName, String levelName ); |
| 116 | |
| 117 | /** |
| 118 | * Returns the name of the parent for the specified logger. |
| 119 | * If the specified logger does not exist, <tt>null</tt> is returned. |
| 120 | * If the specified logger is the root <tt>Logger</tt> in the namespace, |
| 121 | * the result will be an empty string. |
| 122 | * |
| 123 | * @param loggerName The name of a <tt>Logger</tt>. |
| 124 | * |
| 125 | * @return the name of the nearest existing parent logger; |
| 126 | * an empty string if the specified logger is the root logger. |
| 127 | * If the specified logger does not exist, <tt>null</tt> |
| 128 | * is returned. |
| 129 | */ |
| 130 | public String getParentLoggerName(String loggerName); |
| 131 | } |