21 * questions. 22 * 23 */ 24 #include "precompiled.hpp" 25 #include "logging/log.hpp" 26 #include "logging/logConfiguration.hpp" 27 #include "logging/logDecorations.hpp" 28 #include "logging/logDecorators.hpp" 29 #include "logging/logDiagnosticCommand.hpp" 30 #include "logging/logFileOutput.hpp" 31 #include "logging/logOutput.hpp" 32 #include "logging/logTagLevelExpression.hpp" 33 #include "logging/logTagSet.hpp" 34 #include "memory/allocation.inline.hpp" 35 #include "memory/resourceArea.hpp" 36 #include "runtime/os.inline.hpp" 37 #include "utilities/globalDefinitions.hpp" 38 39 LogOutput** LogConfiguration::_outputs = NULL; 40 size_t LogConfiguration::_n_outputs = 0; 41 42 void LogConfiguration::post_initialize() { 43 assert(LogConfiguration_lock != NULL, "Lock must be initialized before post-initialization"); 44 LogDiagnosticCommand::registerCommand(); 45 LogHandle(logging) log; 46 log.info("Log configuration fully initialized."); 47 if (log.is_trace()) { 48 ResourceMark rm; 49 MutexLocker ml(LogConfiguration_lock); 50 describe(log.trace_stream()); 51 } 52 } 53 54 void LogConfiguration::initialize(jlong vm_start_time) { 55 LogFileOutput::set_file_name_parameters(vm_start_time); 56 LogDecorations::set_vm_start_time_millis(vm_start_time); 57 58 assert(_outputs == NULL, "Should not initialize _outputs before this function, initialize called twice?"); 59 _outputs = NEW_C_HEAP_ARRAY(LogOutput*, 2, mtLogging); 60 _outputs[0] = LogOutput::Stdout; 61 _outputs[1] = LogOutput::Stderr; 62 _n_outputs = 2; 63 } 64 65 void LogConfiguration::finalize() { 66 for (size_t i = 2; i < _n_outputs; i++) { 67 delete _outputs[i]; 68 } 69 FREE_C_HEAP_ARRAY(LogOutput*, _outputs); 70 } 71 334 "\t Log messages tagged with 'gc' tag using 'info' level to stdout, with default decorations.\n\n" 335 336 " -Xlog:gc=debug:file=gc.txt:none\n" 337 "\t Log messages tagged with 'gc' tag using 'debug' level to file 'gc.txt' with no decorations.\n\n" 338 339 " -Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1024\n" 340 "\t Log messages tagged with 'gc' tag using 'trace' level to a rotating fileset of 5 files of size 1MB,\n" 341 "\t using the base name 'gctrace.txt', with 'uptimemillis' and 'pid' decorations.\n\n" 342 343 " -Xlog:gc::uptime,tid\n" 344 "\t Log messages tagged with 'gc' tag using 'info' level to output 'stdout', using 'uptime' and 'tid' decorations.\n\n" 345 346 " -Xlog:gc*=info,rt*=off\n" 347 "\t Log messages tagged with at least 'gc' using 'info' level, but turn off logging of messages tagged with 'rt'.\n" 348 "\t (Messages tagged with both 'gc' and 'rt' will not be logged.)\n\n" 349 350 " -Xlog:disable -Xlog:rt=trace:rttrace.txt\n" 351 "\t Turn off all logging, including warnings and errors,\n" 352 "\t and then enable messages tagged with 'rt' using 'trace' level to file 'rttrace.txt'.\n"); 353 } | 21 * questions. 22 * 23 */ 24 #include "precompiled.hpp" 25 #include "logging/log.hpp" 26 #include "logging/logConfiguration.hpp" 27 #include "logging/logDecorations.hpp" 28 #include "logging/logDecorators.hpp" 29 #include "logging/logDiagnosticCommand.hpp" 30 #include "logging/logFileOutput.hpp" 31 #include "logging/logOutput.hpp" 32 #include "logging/logTagLevelExpression.hpp" 33 #include "logging/logTagSet.hpp" 34 #include "memory/allocation.inline.hpp" 35 #include "memory/resourceArea.hpp" 36 #include "runtime/os.inline.hpp" 37 #include "utilities/globalDefinitions.hpp" 38 39 LogOutput** LogConfiguration::_outputs = NULL; 40 size_t LogConfiguration::_n_outputs = 0; 41 bool LogConfiguration::_initialized = false; 42 43 void LogConfiguration::post_initialize() { 44 assert(LogConfiguration_lock != NULL, "Lock must be initialized before post-initialization"); 45 LogDiagnosticCommand::registerCommand(); 46 LogHandle(logging) log; 47 log.info("Log configuration fully initialized."); 48 if (log.is_trace()) { 49 ResourceMark rm; 50 MutexLocker ml(LogConfiguration_lock); 51 describe(log.trace_stream()); 52 } 53 54 _initialized = true; 55 } 56 57 void LogConfiguration::initialize(jlong vm_start_time) { 58 LogFileOutput::set_file_name_parameters(vm_start_time); 59 LogDecorations::set_vm_start_time_millis(vm_start_time); 60 61 assert(_outputs == NULL, "Should not initialize _outputs before this function, initialize called twice?"); 62 _outputs = NEW_C_HEAP_ARRAY(LogOutput*, 2, mtLogging); 63 _outputs[0] = LogOutput::Stdout; 64 _outputs[1] = LogOutput::Stderr; 65 _n_outputs = 2; 66 } 67 68 void LogConfiguration::finalize() { 69 for (size_t i = 2; i < _n_outputs; i++) { 70 delete _outputs[i]; 71 } 72 FREE_C_HEAP_ARRAY(LogOutput*, _outputs); 73 } 74 337 "\t Log messages tagged with 'gc' tag using 'info' level to stdout, with default decorations.\n\n" 338 339 " -Xlog:gc=debug:file=gc.txt:none\n" 340 "\t Log messages tagged with 'gc' tag using 'debug' level to file 'gc.txt' with no decorations.\n\n" 341 342 " -Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1024\n" 343 "\t Log messages tagged with 'gc' tag using 'trace' level to a rotating fileset of 5 files of size 1MB,\n" 344 "\t using the base name 'gctrace.txt', with 'uptimemillis' and 'pid' decorations.\n\n" 345 346 " -Xlog:gc::uptime,tid\n" 347 "\t Log messages tagged with 'gc' tag using 'info' level to output 'stdout', using 'uptime' and 'tid' decorations.\n\n" 348 349 " -Xlog:gc*=info,rt*=off\n" 350 "\t Log messages tagged with at least 'gc' using 'info' level, but turn off logging of messages tagged with 'rt'.\n" 351 "\t (Messages tagged with both 'gc' and 'rt' will not be logged.)\n\n" 352 353 " -Xlog:disable -Xlog:rt=trace:rttrace.txt\n" 354 "\t Turn off all logging, including warnings and errors,\n" 355 "\t and then enable messages tagged with 'rt' using 'trace' level to file 'rttrace.txt'.\n"); 356 } 357 358 void LogConfiguration::rotate_all_outputs() { 359 for (size_t idx = 0; idx < _n_outputs; idx++) { 360 if (_outputs[idx]->is_rotatable()) { 361 _outputs[idx]->rotate(true); 362 } 363 } 364 } 365 |