--- old/src/share/vm/logging/logConfiguration.cpp 2015-10-16 22:52:22.557462700 +0900 +++ new/src/share/vm/logging/logConfiguration.cpp 2015-10-16 22:52:22.391462700 +0900 @@ -35,6 +35,7 @@ #include "memory/resourceArea.hpp" #include "runtime/os.inline.hpp" #include "utilities/globalDefinitions.hpp" +#include "utilities/defaultStream.hpp" LogOutput** LogConfiguration::_outputs = NULL; size_t LogConfiguration::_n_outputs = 0; @@ -351,3 +352,21 @@ "\t Turn off all logging, including warnings and errors,\n" "\t and then enable messages tagged with 'rt' using 'trace' level to file 'rttrace.txt'.\n"); } + +void LogConfiguration::rotate_all_logfile() { + for (size_t idx = 0; idx < _n_outputs; idx++) { + if ((strcmp(_outputs[idx]->name(), "stdout") != 0) && + (strcmp(_outputs[idx]->name(), "stderr") != 0)) { + LogFileOutput *logger = (LogFileOutput *)_outputs[idx]; + + if (logger->get_archive_name() == NULL) { + jio_fprintf(defaultStream::error_stream(), + "Could not rotate log file '%s' because filecount option is not set.\n", + logger->name()); + } else { + logger->rotate(); + } + } + } +} + --- old/src/share/vm/logging/logConfiguration.hpp 2015-10-16 22:52:23.155462700 +0900 +++ new/src/share/vm/logging/logConfiguration.hpp 2015-10-16 22:52:23.004462700 +0900 @@ -85,6 +85,10 @@ // Prints usage help for command line log configuration. static void print_command_line_help(FILE* out); + + // Rotates all LogFileOutput + static void rotate_all_logfile(); + }; #endif // SHARE_VM_LOGGING_LOGCONFIGURATION_HPP --- old/src/share/vm/logging/logDiagnosticCommand.cpp 2015-10-16 22:52:23.691462700 +0900 +++ new/src/share/vm/logging/logDiagnosticCommand.cpp 2015-10-16 22:52:23.531462700 +0900 @@ -35,13 +35,15 @@ _what("what", "Configures what tags to log.", "STRING", false), _decorators("decorators", "Configures which decorators to use. Use 'none' or an empty value to remove all.", "STRING", false), _disable("disable", "Turns off all logging and clears the log configuration.", "BOOLEAN", false), - _list("list", "Lists current log configuration.", "BOOLEAN", false) { + _list("list", "Lists current log configuration.", "BOOLEAN", false), + _rotate("rotate", "Rotates current log.", "BOOLEAN", false) { _dcmdparser.add_dcmd_option(&_output); _dcmdparser.add_dcmd_option(&_output_options); _dcmdparser.add_dcmd_option(&_what); _dcmdparser.add_dcmd_option(&_decorators); _dcmdparser.add_dcmd_option(&_disable); _dcmdparser.add_dcmd_option(&_list); + _dcmdparser.add_dcmd_option(&_rotate); } int LogDiagnosticCommand::num_arguments() { @@ -86,6 +88,11 @@ any_command = true; } + if (_rotate.has_value()) { + LogConfiguration::rotate_all_logfile(); + any_command = true; + } + if (!any_command) { // If no argument was provided, print usage print_help(LogDiagnosticCommand::name()); --- old/src/share/vm/logging/logDiagnosticCommand.hpp 2015-10-16 22:52:24.250462700 +0900 +++ new/src/share/vm/logging/logDiagnosticCommand.hpp 2015-10-16 22:52:24.089462700 +0900 @@ -43,6 +43,7 @@ DCmdArgument _decorators; DCmdArgument _disable; DCmdArgument _list; + DCmdArgument _rotate; public: LogDiagnosticCommand(outputStream* output, bool heap_allocated); @@ -55,7 +56,7 @@ } static const char* description() { - return "Lists, enables, disables or changes a log output configuration."; + return "Lists, enables, disables, changes, or rotates a log output configuration."; } // Used by SecurityManager. This DCMD requires ManagementPermission = control. --- old/src/share/vm/logging/logFileOutput.cpp 2015-10-16 22:52:24.790462700 +0900 +++ new/src/share/vm/logging/logFileOutput.cpp 2015-10-16 22:52:24.641462700 +0900 @@ -156,10 +156,7 @@ _current_size += written; if (should_rotate()) { - MutexLockerEx ml(&_rotation_lock, true /* no safepoint check */); - if (should_rotate()) { - rotate(); - } + rotate(); } return written; @@ -183,6 +180,8 @@ } void LogFileOutput::rotate() { + MutexLockerEx ml(&_rotation_lock, true /* no safepoint check */); + // Archive the current log file archive(); --- old/src/share/vm/logging/logFileOutput.hpp 2015-10-16 22:52:25.345462700 +0900 +++ new/src/share/vm/logging/logFileOutput.hpp 2015-10-16 22:52:25.185462700 +0900 @@ -58,7 +58,6 @@ size_t _current_size; void archive(); - void rotate(); bool configure_rotation(const char* options); char *make_file_name(const char* file_name, const char* pid_string, const char* timestamp_string); static size_t parse_value(const char* value_str); @@ -78,6 +77,12 @@ } static void set_file_name_parameters(jlong start_time); + + void rotate(); + + char *get_archive_name() { + return _archive_name; + } }; #endif // SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP