18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
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
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 }
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
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 #include "utilities/defaultStream.hpp"
39
40 LogOutput** LogConfiguration::_outputs = NULL;
41 size_t LogConfiguration::_n_outputs = 0;
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
55 void LogConfiguration::initialize(jlong vm_start_time) {
56 LogFileOutput::set_file_name_parameters(vm_start_time);
57 LogDecorations::set_vm_start_time_millis(vm_start_time);
58
335 "\t Log messages tagged with 'gc' tag using 'info' level to stdout, with default decorations.\n\n"
336
337 " -Xlog:gc=debug:file=gc.txt:none\n"
338 "\t Log messages tagged with 'gc' tag using 'debug' level to file 'gc.txt' with no decorations.\n\n"
339
340 " -Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1024\n"
341 "\t Log messages tagged with 'gc' tag using 'trace' level to a rotating fileset of 5 files of size 1MB,\n"
342 "\t using the base name 'gctrace.txt', with 'uptimemillis' and 'pid' decorations.\n\n"
343
344 " -Xlog:gc::uptime,tid\n"
345 "\t Log messages tagged with 'gc' tag using 'info' level to output 'stdout', using 'uptime' and 'tid' decorations.\n\n"
346
347 " -Xlog:gc*=info,rt*=off\n"
348 "\t Log messages tagged with at least 'gc' using 'info' level, but turn off logging of messages tagged with 'rt'.\n"
349 "\t (Messages tagged with both 'gc' and 'rt' will not be logged.)\n\n"
350
351 " -Xlog:disable -Xlog:rt=trace:rttrace.txt\n"
352 "\t Turn off all logging, including warnings and errors,\n"
353 "\t and then enable messages tagged with 'rt' using 'trace' level to file 'rttrace.txt'.\n");
354 }
355
356 void LogConfiguration::rotate_all_logfile() {
357 for (size_t idx = 0; idx < _n_outputs; idx++) {
358 if ((strcmp(_outputs[idx]->name(), "stdout") != 0) &&
359 (strcmp(_outputs[idx]->name(), "stderr") != 0)) {
360 LogFileOutput *logger = (LogFileOutput *)_outputs[idx];
361
362 if (logger->get_archive_name() == NULL) {
363 jio_fprintf(defaultStream::error_stream(),
364 "Could not rotate log file '%s' because filecount option is not set.\n",
365 logger->name());
366 } else {
367 logger->rotate();
368 }
369 }
370 }
371 }
372
|