private synchronized void enterSimulationLog(int simulationID) { exitSimulationLog(); if (rootFileHandler != null) { LogFormatter.separator(log, Level.FINE, "Entering log for simulation " + simulationID); try { Logger root = Logger.getLogger(""); String name = logSimPrefix + "_SIM_" + simulationID + ".log"; simLogHandler = new FileHandler(name, true); simLogHandler.setFormatter(formatter); simLogHandler.setLevel(rootFileHandler.getLevel()); simLogName = name; root.addHandler(simLogHandler); root.removeHandler(rootFileHandler); LogFormatter.separator( log, Level.FINE, "Log for simulation " + simulationID + " at " + serverHost + ':' + serverPort + " started"); } catch (Exception e) { log.log(Level.SEVERE, "could not open log file for simulation " + simulationID, e); } } }
private synchronized void exitSimulationLog() { if (simLogHandler != null) { Logger root = Logger.getLogger(""); LogFormatter.separator(log, Level.FINE, "Simulation log complete"); root.addHandler(rootFileHandler); root.removeHandler(simLogHandler); simLogHandler.close(); simLogHandler = null; // Try to remove the lock file since it is no longer needed if (simLogName != null) { new File(simLogName + ".lck").delete(); simLogName = null; } } }
/** * *************************************************************************** * * <p>************************************************************************** */ public static void separator(Logger log, Level level, String title) { separator(log, level, title, title); }