8153723: Change the default logging output for errors and warnings from stderr to stdout
Reviewed-by: mlarsson, sla
--- a/hotspot/src/share/vm/logging/log.cpp Fri May 20 11:30:51 2016 -0700
+++ b/hotspot/src/share/vm/logging/log.cpp Mon May 23 08:02:04 2016 +0200
@@ -578,11 +578,6 @@
LogConfiguration::disable_logging();
assert(Test_logconfiguration_subscribe_triggered == 3, "subscription not triggered (3)");
-
- // We need to renable stderr error logging since "disable_logging" disable it all.
- // TestLogSavedConfig log_cfg will only renable stdout for us.
- LogConfiguration::parse_log_arguments("stderr", "all=warning", NULL, NULL, log.error_stream());
- assert(Test_logconfiguration_subscribe_triggered == 4, "subscription not triggered (3)");
}
#define LOG_PREFIX_STR "THE_PREFIX "
--- a/hotspot/src/share/vm/logging/logFileStreamOutput.hpp Fri May 20 11:30:51 2016 -0700
+++ b/hotspot/src/share/vm/logging/logFileStreamOutput.hpp Mon May 23 08:02:04 2016 +0200
@@ -54,7 +54,7 @@
private:
static LogStdoutOutput _instance;
LogStdoutOutput() : LogFileStreamOutput(stdout) {
- set_config_string("all=off");
+ set_config_string("all=warning");
}
virtual bool initialize(const char* options, outputStream* errstream) {
return false;
@@ -70,7 +70,7 @@
private:
static LogStderrOutput _instance;
LogStderrOutput() : LogFileStreamOutput(stderr) {
- set_config_string("all=warning");
+ set_config_string("all=off");
}
virtual bool initialize(const char* options, outputStream* errstream) {
return false;
--- a/hotspot/src/share/vm/logging/logTagSet.cpp Fri May 20 11:30:51 2016 -0700
+++ b/hotspot/src/share/vm/logging/logTagSet.cpp Mon May 23 08:02:04 2016 +0200
@@ -50,7 +50,7 @@
_ntagsets++;
// Set the default output to warning and error level for all new tagsets.
- _output_list.set_output_level(LogOutput::Stderr, LogLevel::Default);
+ _output_list.set_output_level(LogOutput::Stdout, LogLevel::Default);
}
void LogTagSet::update_decorators(const LogDecorators& decorator) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/logging/TestDefaultLogOutput.java Mon May 23 08:02:04 2016 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test TestDefaultLogOutput
+ * @summary Ensure logging is default on stdout.
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary
+ */
+
+import jdk.test.lib.ProcessTools;
+import jdk.test.lib.OutputAnalyzer;
+
+public class TestDefaultLogOutput {
+
+ public static void main(String[] args) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:badTag");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.stdoutShouldMatch("\\[error *\\]\\[logging *\\]");
+ output.shouldHaveExitValue(1);
+ }
+}
+