1 /* 2 * Copyright (c) 2003, 2008, Oracle and/or its affiliates. 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.util.logging; 27 28 29 /** 30 * The management interface for the logging facility. 31 * 32 * <p>There is a single global instance of the <tt>LoggingMXBean</tt>. 33 * This instance is an 34 * <a href="../../lang/management/ManagementFactory.html#MXBean">MXBean</a> 35 * can be obtained by calling 36 * the {@link LogManager#getLoggingMXBean} method or from the 37 * {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer 38 * platform <tt>MBeanServer</tt>}. 39 * 40 * The {@link javax.management.ObjectName ObjectName} for uniquely 41 * identifying the <tt>LoggingMXBean</tt> within an MBeanServer is: 42 * <blockquote> 43 * {@link LogManager#LOGGING_MXBEAN_NAME 44 * <tt>java.util.logging:type=Logging</tt>} 45 * </blockquote> 46 * 47 * The instance registered in the platform <tt>MBeanServer</tt> with 48 * this {@code ObjectName} is also a {@link PlatformLoggingMXBean}. 49 * 50 * @author Ron Mann 51 * @author Mandy Chung 52 * @since 1.5 53 * 54 * @see PlatformLoggingMXBean 55 */ 56 public interface LoggingMXBean { 57 58 /** 59 * Returns the list of currently registered loggers. This method 60 * calls {@link LogManager#getLoggerNames} and returns a list 61 * of the logger names. 62 * 63 * @return A list of <tt>String</tt> each of which is a 64 * currently registered <tt>Logger</tt> name. 65 */ 66 public java.util.List<String> getLoggerNames(); 67 68 /** 69 * Gets the name of the log level associated with the specified logger. 70 * If the specified logger does not exist, <tt>null</tt> 71 * is returned. 72 * This method first finds the logger of the given name and 73 * then returns the name of the log level by calling: 74 * <blockquote> 75 * {@link Logger#getLevel Logger.getLevel()}.{@link Level#getName getName()}; 76 * </blockquote> 77 * 78 * <p> 79 * If the <tt>Level</tt> of the specified logger is <tt>null</tt>, 80 * which means that this logger's effective level is inherited 81 * from its parent, an empty string will be returned. 82 * 83 * @param loggerName The name of the <tt>Logger</tt> to be retrieved. 84 * 85 * @return The name of the log level of the specified logger; or 86 * an empty string if the log level of the specified logger 87 * is <tt>null</tt>. If the specified logger does not 88 * exist, <tt>null</tt> is returned. 89 * 90 * @see Logger#getLevel 91 */ 92 public String getLoggerLevel( String loggerName ); 93 94 /** 95 * Sets the specified logger to the specified new level. 96 * If the <tt>levelName</tt> is not <tt>null</tt>, the level 97 * of the specified logger is set to the parsed <tt>Level</tt> 98 * matching the <tt>levelName</tt>. 99 * If the <tt>levelName</tt> is <tt>null</tt>, the level 100 * of the specified logger is set to <tt>null</tt> and 101 * the effective level of the logger is inherited from 102 * its nearest ancestor with a specific (non-null) level value. 103 * 104 * @param loggerName The name of the <tt>Logger</tt> to be set. 105 * Must be non-null. 106 * @param levelName The name of the level to set on the specified logger, 107 * or <tt>null</tt> if setting the level to inherit 108 * from its nearest ancestor. 109 * 110 * @throws IllegalArgumentException if the specified logger 111 * does not exist, or <tt>levelName</tt> is not a valid level name. 112 * 113 * @throws SecurityException if a security manager exists and if 114 * the caller does not have LoggingPermission("control"). 115 * 116 * @see Logger#setLevel 117 */ 118 public void setLoggerLevel( String loggerName, String levelName ); 119 120 /** 121 * Returns the name of the parent for the specified logger. 122 * If the specified logger does not exist, <tt>null</tt> is returned. 123 * If the specified logger is the root <tt>Logger</tt> in the namespace, 124 * the result will be an empty string. 125 * 126 * @param loggerName The name of a <tt>Logger</tt>. 127 * 128 * @return the name of the nearest existing parent logger; 129 * an empty string if the specified logger is the root logger. 130 * If the specified logger does not exist, <tt>null</tt> 131 * is returned. 132 */ 133 public String getParentLoggerName(String loggerName); 134 }