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