diff --git a/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java b/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java index 4ca5320dd9bbe31313687a3d2ef727e48cf7d4fd..a4ee809ee6ab8023567709f7da81767bd1ba3e2b 100755 --- a/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java +++ b/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004-2011 QOS.ch + * Copyright (c) 2004-2013 QOS.ch * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining @@ -110,15 +110,18 @@ public class SLF4JBridgeHandler extends Handler { /** * Adds a SLF4JBridgeHandler instance to jul's root logger. *
- * + *
* This handler will redirect j.u.l. logging to SLF4J. However, only logs enabled
* in j.u.l. will be redirected. For example, if a log statement invoking a
* j.u.l. logger is disabled, then the corresponding non-event will not
* reach SLF4JBridgeHandler and cannot be redirected.
+ *
+ * @throws SecurityException A SecurityException
is thrown, if a security manager
+ * exists and if the caller does not have
+ * LoggingPermission("control").
*/
- public static void install() {
- LogManager.getLogManager().getLogger("").addHandler(
- new SLF4JBridgeHandler());
+ public static void install() throws SecurityException {
+ getRootLogger().getLogger("").addHandler(new SLF4JBridgeHandler());
}
private static java.util.logging.Logger getRootLogger() {
@@ -147,7 +150,10 @@ public class SLF4JBridgeHandler extends Handler {
* Returns true if SLF4JBridgeHandler has been previously installed, returns false otherwise.
*
* @return true if SLF4JBridgeHandler is already installed, false other wise
- * @throws SecurityException
+ *
+ * @throws SecurityException A SecurityException
is thrown, if a security manager
+ * exists and if the caller does not have
+ * LoggingPermission("control").
*/
public static boolean isInstalled() throws SecurityException {
java.util.logging.Logger rootLogger = getRootLogger();
@@ -161,10 +167,14 @@ public class SLF4JBridgeHandler extends Handler {
}
/**
- * Invoking this method removes/unregisters/detaches all handlers currently attached to the root logger
+ * Invoking this method removes/unregisters/detaches all handlers currently attached to the root logger.
+ *
+ * @throws SecurityException A SecurityException
is thrown, if a security manager
+ * exists and if the caller does not have
+ * LoggingPermission("control").
* @since 1.6.5
*/
- public static void removeHandlersForRootLogger() {
+ public static void removeHandlersForRootLogger() throws SecurityException {
java.util.logging.Logger rootLogger = getRootLogger();
java.util.logging.Handler[] handlers = rootLogger.getHandlers();
for (int i = 0; i < handlers.length; i++) {