summaryrefslogtreecommitdiff
path: root/java/util/logging/LogManager.java
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-06-27 20:01:40 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-06-27 20:01:40 +0000
commit3b00aa20227be4b0f2314278dcea3ef3739c44aa (patch)
treef7d11ad3bf3342c619595f748dbb91b184b8324c /java/util/logging/LogManager.java
parent78c2fbfb5f722402791ad87028a3a5f62ed4c086 (diff)
downloadclasspath-3b00aa20227be4b0f2314278dcea3ef3739c44aa.tar.gz
2006-06-27 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD --> generics-branch for 2006/06/16 to 2006/06/27.
Diffstat (limited to 'java/util/logging/LogManager.java')
-rw-r--r--java/util/logging/LogManager.java76
1 files changed, 74 insertions, 2 deletions
diff --git a/java/util/logging/LogManager.java b/java/util/logging/LogManager.java
index ae0f446a8..444ab6a26 100644
--- a/java/util/logging/LogManager.java
+++ b/java/util/logging/LogManager.java
@@ -39,6 +39,8 @@ exception statement from your version. */
package java.util.logging;
+import gnu.classpath.SystemProperties;
+
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.ByteArrayInputStream;
@@ -50,12 +52,11 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
-import gnu.classpath.SystemProperties;
-
/**
* The <code>LogManager</code> maintains a hierarchical namespace
* of Logger objects and manages properties for configuring the logging
@@ -108,11 +109,23 @@ import gnu.classpath.SystemProperties;
public class LogManager
{
/**
+ * The object name for the logging management bean.
+ * @since 1.5
+ */
+ public static final String LOGGING_MXBEAN_NAME
+ = "java.util.logging:type=Logging";
+
+ /**
* The singleton LogManager instance.
*/
private static LogManager logManager;
/**
+ * The singleton logging bean.
+ */
+ private static LoggingMXBean loggingBean;
+
+ /**
* The registered named loggers; maps the name of a Logger to
* a WeakReference to it.
*/
@@ -902,4 +915,63 @@ public class LogManager
}
}
+ /**
+ * Return the logging bean. There is a single logging bean per
+ * VM instance.
+ * @since 1.5
+ */
+ public static synchronized LoggingMXBean getLoggingMXBean()
+ {
+ if (loggingBean == null)
+ {
+ loggingBean = new LoggingMXBean()
+ {
+ public String getLoggerLevel(String logger)
+ {
+ LogManager mgr = getLogManager();
+ Logger l = mgr.getLogger(logger);
+ if (l == null)
+ return null;
+ Level lev = l.getLevel();
+ if (lev == null)
+ return "";
+ return lev.getName();
+ }
+
+ public List getLoggerNames()
+ {
+ LogManager mgr = getLogManager();
+ // This is inefficient, but perhaps better for maintenance.
+ return Collections.list(mgr.getLoggerNames());
+ }
+
+ public String getParentLoggerName(String logger)
+ {
+ LogManager mgr = getLogManager();
+ Logger l = mgr.getLogger(logger);
+ if (l == null)
+ return null;
+ l = l.getParent();
+ if (l == null)
+ return "";
+ return l.getName();
+ }
+
+ public void setLoggerLevel(String logger, String level)
+ {
+ LogManager mgr = getLogManager();
+ Logger l = mgr.getLogger(logger);
+ if (l == null)
+ throw new IllegalArgumentException("no logger named " + logger);
+ Level newLevel;
+ if (level == null)
+ newLevel = null;
+ else
+ newLevel = Level.parse(level);
+ l.setLevel(newLevel);
+ }
+ };
+ }
+ return loggingBean;
+ }
}