diff --git a/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JavaDebuggerServerPlugin.java b/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JavaDebuggerServerPlugin.java index 9f4e723ec..975338371 100644 --- a/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JavaDebuggerServerPlugin.java +++ b/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JavaDebuggerServerPlugin.java @@ -35,6 +35,7 @@ public void start(BundleContext context) throws Exception { @Override public void stop(BundleContext context) throws Exception { logger.info("Stopping " + PLUGIN_ID); + LogUtils.cleanupHandlers(); } } diff --git a/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/LogUtils.java b/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/LogUtils.java index 16c35d859..259631d30 100644 --- a/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/LogUtils.java +++ b/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/LogUtils.java @@ -11,6 +11,7 @@ package com.microsoft.java.debug.plugin.internal; +import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.Logger; @@ -32,6 +33,21 @@ public static void initialize(Level level) { logger.setLevel(level); } + /** + * Remove the logger handlers registered to the global logger. + */ + public static void cleanupHandlers() { + Handler[] handlers = logger.getHandlers(); + for (Handler handler : handlers) { + logger.removeHandler(handler); + } + + Handler[] usageHandlers = usageDataLogger.getHandlers(); + for (Handler handler : usageHandlers) { + usageDataLogger.removeHandler(handler); + } + } + /** * Configure log level setting for java debugger. *