opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ControlPanelLauncher.java
@@ -100,6 +100,7 @@ // then print it and exit. if (argParser.usageOrVersionDisplayed()) { ControlPanelLog.closeAndDeleteLogFile(); System.exit(ErrorReturnCode.SUCCESSFUL_NOP.getReturnCode()); } @@ -143,6 +144,7 @@ System.exit(exitCode); } } ControlPanelLog.closeAndDeleteLogFile(); } /** opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ControlPanelLog.java
@@ -47,8 +47,7 @@ private static FileHandler fileHandler; /** * Creates a new file handler for writing log messages to the file indicated * by <code>file</code>. * Creates a new file handler for writing log messages to the file indicated by <code>file</code>. * @param file log file to which log messages will be written * @throws IOException if something goes wrong */ @@ -76,9 +75,8 @@ } /** * Writes messages under a given package in the file handler defined when * calling initLogFileHandler. Note that initLogFileHandler should be called * before calling this method. * Writes messages under a given package in the file handler defined when calling initLogFileHandler. * Note that initLogFileHandler should be called before calling this method. * @param packageName the package name. * @throws IOException if something goes wrong */ @@ -108,12 +106,21 @@ return logFile != null; } private static String getInitialLogRecord() { /** Closes the log file and deletes it. */ public static void closeAndDeleteLogFile() { if (logFile != null) { fileHandler.close(); logFile.delete(); } } private static String getInitialLogRecord() { StringBuilder sb = new StringBuilder() .append("Application launched " + DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG). format(new Date())); DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(new Date())); return sb.toString(); } opendj-server-legacy/src/main/java/org/opends/quicksetup/QuickSetupLog.java
@@ -44,8 +44,7 @@ private static FileHandler FILE_HANDLER; /** * Creates a new file handler for writing log messages to the file indicated * by <code>file</code>. * Creates a new file handler for writing log messages to the file indicated by <code>file</code>. * * @param file * log file to which log messages will be written @@ -68,8 +67,7 @@ } /** * Creates a new file handler for writing log messages of a given package to * the file indicated by <code>file</code>. * Creates a new file handler for writing log messages of a given package to the file indicated by <code>file</code>. * * @param file * log file to which log messages will be written. @@ -115,6 +113,16 @@ return LOG_FILE != null; } /** Closes the log file and deletes it. */ public static void closeAndDeleteLogFile() { if (LOG_FILE != null) { FILE_HANDLER.close(); LOG_FILE.delete(); } } private static String getInitialLogRecord() { // Note; currently the logs are not internationalized. opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDS.java
@@ -309,7 +309,12 @@ final InstallDS install = new InstallDS(out, err, inStream); return install.execute(args); int retCode = install.execute(args); if (retCode == 0) { QuickSetupLog.closeAndDeleteLogFile(); } return retCode; } /** opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -365,6 +365,11 @@ } ReplicationCliMain replicationCli = new ReplicationCliMain(out, err); ReplicationCliReturnCode result = replicationCli.execute(args, initializeServer); if (result.getReturnCode() == 0) { // Delete the temp log file, in case of success. ControlPanelLog.closeAndDeleteLogFile(); } return result.getReturnCode(); } opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
@@ -201,7 +201,12 @@ } final StatusCli statusCli = new StatusCli(out, err, inStream); return statusCli.execute(args); int retCode = statusCli.execute(args); if (retCode == 0) { ControlPanelLog.closeAndDeleteLogFile(); } return retCode; } /**