1   /*
2    * %W% %E%
3    *
4    * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
5    * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6    */
7   
8   package java.util.logging;
9   
10  /** 
11   * The management interface for the logging facility.
12   *
13   * <p>There is a single global instance of the <tt>LoggingMXBean</tt>.
14   * This instance is an 
15   * <a href="../../lang/management/ManagementFactory.html#MXBean">MXBean</a>
16   * can be obtained by calling
17   * the {@link LogManager#getLoggingMXBean} method or from the 
18   * {@link java.lang.management.ManagementFactory#getPlatformMBeanServer
19   * platform <tt>MBeanServer</tt>} method.
20   *
21   * <p>The {@link javax.management.ObjectName ObjectName} for uniquely 
22   * identifying the <tt>LoggingMXBean</tt> within an MBeanServer is:
23   * <blockquote>
24   *    {@link LogManager#LOGGING_MXBEAN_NAME
25   *           <tt>java.util.logging:type=Logging</tt>}
26   * </blockquote>
27   *
28   * @see java.lang.management.ManagementFactory
29   *
30   * @author  Ron Mann 
31   * @author  Mandy Chung
32   * @version %I%, %G%
33   * @since   1.5
34   *
35   */
36  public interface LoggingMXBean {
37   
38      /** 
39       * Returns the list of currently registered loggers. This method
40       * calls {@link LogManager#getLoggerNames} and returns a list 
41       * of the logger names.
42       * 
43       * @return A list of <tt>String</tt> each of which is a
44       *         currently registered <tt>Logger</tt> name.
45       */
46      public java.util.List<String> getLoggerNames();
47  
48      /** 
49       * Gets the name of the log level associated with the specified logger.
50       * If the specified logger does not exist, <tt>null</tt> 
51       * is returned. 
52       * This method first finds the logger of the given name and 
53       * then returns the name of the log level by calling:
54       * <blockquote>
55       *   {@link Logger#getLevel Logger.getLevel()}.{@link Level#getName getName()};
56       * </blockquote>
57       *  
58       * <p>
59       * If the <tt>Level</tt> of the specified logger is <tt>null</tt>, 
60       * which means that this logger's effective level is inherited 
61       * from its parent, an empty string will be returned.
62       * 
63       * @param loggerName The name of the <tt>Logger</tt> to be retrieved.
64       *
65       * @return The name of the log level of the specified logger; or
66       *         an empty string if the log level of the specified logger
67       *         is <tt>null</tt>.  If the specified logger does not
68       *         exist, <tt>null</tt> is returned.
69       *
70       * @see Logger#getLevel
71       */
72      public String getLoggerLevel( String loggerName );
73  
74      /** 
75       * Sets the specified logger to the specified new level.
76       * If the <tt>levelName</tt> is not <tt>null</tt>, the level
77       * of the specified logger is set to the parsed <tt>Level</tt>
78       * matching the <tt>levelName</tt>.
79       * If the <tt>levelName</tt> is <tt>null</tt>, the level
80       * of the specified logger is set to <tt>null</tt> and
81       * the effective level of the logger is inherited from 
82       * its nearest ancestor with a specific (non-null) level value.
83       *
84       * @param loggerName The name of the <tt>Logger</tt> to be set.
85       *                   Must be non-null.
86       * @param levelName The name of the level to set the specified logger to, 
87       *                 or <tt>null</tt> if to set the level to inherit
88       *                 from its nearest ancestor.
89       *
90       * @throws IllegalArgumentException if the specified logger 
91       * does not exist, or <tt>levelName</tt> is not a valid level name.
92       *
93       * @throws SecurityException if a security manager exists and if
94       * the caller does not have LoggingPermission("control").
95       *
96       * @see Logger#setLevel
97       */
98      public void setLoggerLevel( String loggerName, String levelName );
99  
100     /**
101      * Returns the name of the parent for the specified logger.
102      * If the specified logger does not exist, <tt>null</tt> is returned. 
103      * If the specified logger is the root <tt>Logger</tt> in the namespace,
104      * the result will be an empty string.
105      *
106      * @param loggerName The name of a <tt>Logger</tt>.
107      *
108      * @return the name of the nearest existing parent logger;
109      *         an empty string if the specified logger is the root logger.
110      *         If the specified logger does not exist, <tt>null</tt> 
111      *         is returned. 
112      */
113     public String getParentLoggerName(String loggerName);
114 }
115