From: David ‘Bombe’ Roden Date: Tue, 21 Jul 2015 20:46:34 +0000 (+0200) Subject: Clean up logger on shutdown X-Git-Tag: 0.9.3^2~8 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=727e7379ef462d304a4c72a51e69a4825d661ea1;p=Sone.git Clean up logger on shutdown --- 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 //