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