LoggingMXBean.java revision 00bdcb8238d4d4172e49572cbb23927836ded7ae
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
26package 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 *
34 * The {@code javax.management.ObjectName ObjectName} that uniquely identifies
35 * the management interface for logging within the {@code MBeanServer} is:
36 * <pre>
37 *    {@link LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}
38 * </pre>
39 * <p>
40 *
41 * @author  Ron Mann
42 * @author  Mandy Chung
43 * @since   1.5
44 *
45 */
46
47// Android-removed : References to java.lang.management.
48//
49// It is recommended
50// to use the {@link java.lang.management.PlatformLoggingMXBean} management
51// interface that implements all attributes defined in this
52// {@code LoggingMXBean}.  The
53// {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
54// ManagementFactory.getPlatformMXBean} method can be used to obtain
55// the {@code PlatformLoggingMXBean} object representing the management
56// interface for logging.
57//
58// This instance is an {@link javax.management.MXBean MXBean} that
59// can be obtained by calling the {@link LogManager#getLoggingMXBean}
60// method or from the
61// {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
62// platform <tt>MBeanServer</tt>}.
63//
64// The instance registered in the platform {@code MBeanServer}
65// is also a {@link java.lang.management.PlatformLoggingMXBean}.
66//
67// @see java.lang.management.PlatformLoggingMXBean
68public interface LoggingMXBean {
69
70    /**
71     * Returns the list of currently registered logger names. This method
72     * calls {@link LogManager#getLoggerNames} and returns a list
73     * of the logger names.
74     *
75     * @return A list of <tt>String</tt> each of which is a
76     *         currently registered <tt>Logger</tt> name.
77     */
78    public java.util.List<String> getLoggerNames();
79
80    /**
81     * Gets the name of the log level associated with the specified logger.
82     * If the specified logger does not exist, <tt>null</tt>
83     * is returned.
84     * This method first finds the logger of the given name and
85     * then returns the name of the log level by calling:
86     * <blockquote>
87     *   {@link Logger#getLevel Logger.getLevel()}.{@link Level#getName getName()};
88     * </blockquote>
89     *
90     * <p>
91     * If the <tt>Level</tt> of the specified logger is <tt>null</tt>,
92     * which means that this logger's effective level is inherited
93     * from its parent, an empty string will be returned.
94     *
95     * @param loggerName The name of the <tt>Logger</tt> to be retrieved.
96     *
97     * @return The name of the log level of the specified logger; or
98     *         an empty string if the log level of the specified logger
99     *         is <tt>null</tt>.  If the specified logger does not
100     *         exist, <tt>null</tt> is returned.
101     *
102     * @see Logger#getLevel
103     */
104    public String getLoggerLevel(String loggerName);
105
106    /**
107     * Sets the specified logger to the specified new level.
108     * If the <tt>levelName</tt> is not <tt>null</tt>, the level
109     * of the specified logger is set to the parsed <tt>Level</tt>
110     * matching the <tt>levelName</tt>.
111     * If the <tt>levelName</tt> is <tt>null</tt>, the level
112     * of the specified logger is set to <tt>null</tt> and
113     * the effective level of the logger is inherited from
114     * its nearest ancestor with a specific (non-null) level value.
115     *
116     * @param loggerName The name of the <tt>Logger</tt> to be set.
117     *                   Must be non-null.
118     * @param levelName The name of the level to set on the specified logger,
119     *                 or <tt>null</tt> if setting the level to inherit
120     *                 from its nearest ancestor.
121     *
122     * @throws IllegalArgumentException if the specified logger
123     * does not exist, or <tt>levelName</tt> is not a valid level name.
124     *
125     * @throws SecurityException if a security manager exists and if
126     * the caller does not have LoggingPermission("control").
127     *
128     * @see Logger#setLevel
129     */
130    public void setLoggerLevel(String loggerName, String levelName);
131
132    /**
133     * Returns the name of the parent for the specified logger.
134     * If the specified logger does not exist, <tt>null</tt> is returned.
135     * If the specified logger is the root <tt>Logger</tt> in the namespace,
136     * the result will be an empty string.
137     *
138     * @param loggerName The name of a <tt>Logger</tt>.
139     *
140     * @return the name of the nearest existing parent logger;
141     *         an empty string if the specified logger is the root logger.
142     *         If the specified logger does not exist, <tt>null</tt>
143     *         is returned.
144     */
145    public String getParentLoggerName(String loggerName);
146}
147