CLI: Delay shutdown of logging system until the end of the stop() method
This commit is contained in:
@@ -13,6 +13,7 @@ import java.io.PrintStream;
|
||||
import java.util.Scanner;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@@ -20,8 +21,22 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class CLILogger {
|
||||
|
||||
static {
|
||||
System.setProperty("java.util.logging.manager", ShutdownHookDelayerLogManager.class.getName());
|
||||
}
|
||||
|
||||
private static Logger logger = null;
|
||||
|
||||
|
||||
public static class ShutdownHookDelayerLogManager extends LogManager {
|
||||
static ShutdownHookDelayerLogManager instance;
|
||||
public ShutdownHookDelayerLogManager() { instance = this; }
|
||||
@Override public void reset() { /* don't reset yet. */ }
|
||||
private void reset0() { super.reset(); }
|
||||
public static void resetFinally() { instance.reset0(); }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize and return the logger for this application.
|
||||
* @param cli the CLI instance to use
|
||||
|
Reference in New Issue
Block a user