Path: blob/master/src/java.management/share/classes/java/lang/management/PlatformLoggingMXBean.java
41159 views
/*1* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.lang.management;2627/**28* The management interface for the {@linkplain java.util.logging logging} facility.29*30* <p>There is a single global instance of the {@code PlatformLoggingMXBean}.31* The {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)32* ManagementFactory.getPlatformMXBean} method can be used to obtain33* the {@code PlatformLoggingMXBean} object as follows:34* <pre>35* PlatformLoggingMXBean logging = ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class);36* </pre>37* The {@code PlatformLoggingMXBean} object is also registered with the38* platform {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer39* MBeanServer}.40* The {@link javax.management.ObjectName ObjectName} for uniquely41* identifying the {@code PlatformLoggingMXBean} within an MBeanServer is:42* <pre>43* {@link java.util.logging.LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}44* </pre>45*46* @since 1.747*/48public interface PlatformLoggingMXBean extends PlatformManagedObject {4950/**51* Returns the list of the currently registered52* {@linkplain java.util.logging.Logger logger} names. This method53* calls {@link java.util.logging.LogManager#getLoggerNames} and54* returns a list of the logger names.55*56* @return A list of {@code String} each of which is a57* currently registered {@code Logger} name.58*/59java.util.List<String> getLoggerNames();6061/**62* Gets the name of the log {@linkplain java.util.logging.Logger#getLevel63* level} associated with the specified logger.64* If the specified logger does not exist, {@code null}65* is returned.66* This method first finds the logger of the given name and67* then returns the name of the log level by calling:68* <blockquote>69* {@link java.util.logging.Logger#getLevel70* Logger.getLevel()}.{@link java.util.logging.Level#getName getName()};71* </blockquote>72*73* <p>74* If the {@code Level} of the specified logger is {@code null},75* which means that this logger's effective level is inherited76* from its parent, an empty string will be returned.77*78* @param loggerName The name of the {@code Logger} to be retrieved.79*80* @return The name of the log level of the specified logger; or81* an empty string if the log level of the specified logger82* is {@code null}. If the specified logger does not83* exist, {@code null} is returned.84*85* @see java.util.logging.Logger#getLevel86*/87String getLoggerLevel(String loggerName);8889/**90* Sets the specified logger to the specified new91* {@linkplain java.util.logging.Logger#setLevel level}.92* If the {@code levelName} is not {@code null}, the level93* of the specified logger is set to the parsed94* {@link java.util.logging.Level Level}95* matching the {@code levelName}.96* If the {@code levelName} is {@code null}, the level97* of the specified logger is set to {@code null} and98* the effective level of the logger is inherited from99* its nearest ancestor with a specific (non-null) level value.100*101* @param loggerName The name of the {@code Logger} to be set.102* Must be non-null.103* @param levelName The name of the level to set on the specified logger,104* or {@code null} if setting the level to inherit105* from its nearest ancestor.106*107* @throws IllegalArgumentException if the specified logger108* does not exist, or {@code levelName} is not a valid level name.109*110* @throws SecurityException if a security manager exists and if111* the caller does not have LoggingPermission("control").112*113* @see java.util.logging.Logger#setLevel114*/115void setLoggerLevel(String loggerName, String levelName);116117/**118* Returns the name of the119* {@linkplain java.util.logging.Logger#getParent parent}120* for the specified logger.121* If the specified logger does not exist, {@code null} is returned.122* If the specified logger is the root {@code Logger} in the namespace,123* the result will be an empty string.124*125* @param loggerName The name of a {@code Logger}.126*127* @return the name of the nearest existing parent logger;128* an empty string if the specified logger is the root logger.129* If the specified logger does not exist, {@code null}130* is returned.131*/132String getParentLoggerName(String loggerName);133}134135136