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