jdk/src/share/classes/java/util/logging/LoggingMXBean.java
author alanb
Fri, 02 Nov 2012 15:50:11 +0000
changeset 14342 8435a30053c1
parent 9013 eedac0b9f552
permissions -rw-r--r--
7197491: update copyright year to match last edit in jdk8 jdk repository Reviewed-by: chegar, ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 9013
diff changeset
     2
 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4172
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4172
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4172
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4172
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4172
diff changeset
    23
 * questions.
2
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
/**
9013
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    30
 * The management interface for the logging facility. It is recommended
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    31
 * to use the {@link java.lang.management.PlatformLoggingMXBean} management
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    32
 * interface that implements all attributes defined in this
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    33
 * {@code LoggingMXBean}.  The
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    34
 * {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    35
 * ManagementFactory.getPlatformMXBean} method can be used to obtain
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    36
 * the {@code PlatformLoggingMXBean} object representing the management
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    37
 * interface for logging.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <p>There is a single global instance of the <tt>LoggingMXBean</tt>.
9013
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    40
 * This instance is an {@link javax.management.MXBean MXBean} that
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    41
 * can be obtained by calling the {@link LogManager#getLoggingMXBean}
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    42
 * method or from the
4172
bceea7bc12b7 6876135: Add PlatformLoggingMXBean to eliminate the dependency on JMX from logging
mchung
parents: 3853
diff changeset
    43
 * {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
bceea7bc12b7 6876135: Add PlatformLoggingMXBean to eliminate the dependency on JMX from logging
mchung
parents: 3853
diff changeset
    44
 * platform <tt>MBeanServer</tt>}.
9013
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    45
 * <p>
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    46
 * The {@link javax.management.ObjectName ObjectName} that uniquely identifies
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    47
 * the management interface for logging within the {@code MBeanServer} is:
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    48
 * <pre>
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    49
 *    {@link LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    50
 * </pre>
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    51
 * <p>
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    52
 * The instance registered in the platform {@code MBeanServer}
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    53
 * is also a {@link java.lang.management.PlatformLoggingMXBean}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @author  Ron Mann
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @author  Mandy Chung
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @since   1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
9013
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    59
 * @see java.lang.management.PlatformLoggingMXBean
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 */
4172
bceea7bc12b7 6876135: Add PlatformLoggingMXBean to eliminate the dependency on JMX from logging
mchung
parents: 3853
diff changeset
    61
public interface LoggingMXBean {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /**
9013
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    64
     * Returns the list of currently registered logger names. This method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * calls {@link LogManager#getLoggerNames} and returns a list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * of the logger names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @return A list of <tt>String</tt> each of which is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *         currently registered <tt>Logger</tt> name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public java.util.List<String> getLoggerNames();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Gets the name of the log level associated with the specified logger.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * If the specified logger does not exist, <tt>null</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * This method first finds the logger of the given name and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * then returns the name of the log level by calling:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *   {@link Logger#getLevel Logger.getLevel()}.{@link Level#getName getName()};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * If the <tt>Level</tt> of the specified logger is <tt>null</tt>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * which means that this logger's effective level is inherited
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * from its parent, an empty string will be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @param loggerName The name of the <tt>Logger</tt> to be retrieved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @return The name of the log level of the specified logger; or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *         an empty string if the log level of the specified logger
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *         is <tt>null</tt>.  If the specified logger does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *         exist, <tt>null</tt> is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @see Logger#getLevel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
9013
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    97
    public String getLoggerLevel(String loggerName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Sets the specified logger to the specified new level.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * If the <tt>levelName</tt> is not <tt>null</tt>, the level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * of the specified logger is set to the parsed <tt>Level</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * matching the <tt>levelName</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * If the <tt>levelName</tt> is <tt>null</tt>, the level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * of the specified logger is set to <tt>null</tt> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * the effective level of the logger is inherited from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * its nearest ancestor with a specific (non-null) level value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @param loggerName The name of the <tt>Logger</tt> to be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *                   Must be non-null.
3853
9d2382b74894 6882363: 4/4 typos in java.util.logging javadocs
dcubed
parents: 715
diff changeset
   111
     * @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
   112
     *                 or <tt>null</tt> if setting the level to inherit
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *                 from its nearest ancestor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @throws IllegalArgumentException if the specified logger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * does not exist, or <tt>levelName</tt> is not a valid level name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @throws SecurityException if a security manager exists and if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * the caller does not have LoggingPermission("control").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @see Logger#setLevel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
9013
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
   123
    public void setLoggerLevel(String loggerName, String levelName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Returns the name of the parent for the specified logger.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * If the specified logger does not exist, <tt>null</tt> is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * If the specified logger is the root <tt>Logger</tt> in the namespace,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * the result will be an empty string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param loggerName The name of a <tt>Logger</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @return the name of the nearest existing parent logger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *         an empty string if the specified logger is the root logger.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *         If the specified logger does not exist, <tt>null</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *         is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public String getParentLoggerName(String loggerName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
}