From 727e7379ef462d304a4c72a51e69a4825d661ea1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 21 Jul 2015 22:46:34 +0200 Subject: [PATCH] Clean up logger on shutdown --- src/main/java/net/pterodactylus/sone/main/SonePlugin.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index 17340b8..e63241b 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -75,9 +75,10 @@ import freenet.support.api.Bucket; */ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, FredPluginBaseL10n, FredPluginThreadless, FredPluginVersioned { + private static final Logger soneLogger = getLogger("net.pterodactylus.sone"); + static { /* initialize logging. */ - Logger soneLogger = getLogger("net.pterodactylus.sone"); soneLogger.setUseParentHandlers(false); soneLogger.addHandler(new Handler() { private final LoadingCache> classCache = CacheBuilder.newBuilder() @@ -295,6 +296,7 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr */ @Override public void terminate() { + deregisterLoggerHandlers(); try { /* stop the web interface. */ webInterface.stop(); @@ -309,6 +311,12 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr } } + private void deregisterLoggerHandlers() { + for (Handler handler : soneLogger.getHandlers()) { + soneLogger.removeHandler(handler); + } + } + // // INTERFACE FredPluginFCP // -- 2.7.4