@Override public void stop() { scheduledExecutor.shutdown(); processLogEntries(); if (registeredObjectName != null) { try { mbeanServer.unregisterMBean(registeredObjectName); } catch (Exception e) { addWarn("Exception unRegistering mbean " + registeredObjectName, e); } } try { scheduledExecutor.awaitTermination(2 * this.flushIntervalInSeconds, TimeUnit.SECONDS); } catch (InterruptedException e) { addWarn("Exception waiting for termination of LogglyAppender scheduler", e); } // stop appender (ie close outputStream) after sending it to Loggly outputStream.close(); super.stop(); }