8153723: Change the default logging output for errors and warnings from stderr to stdout
Reviewed-by: mlarsson, sla
This commit is contained in:
parent
a4eeccb502
commit
2096e37c4e
@ -578,11 +578,6 @@ void Test_logconfiguration_subscribe() {
|
|||||||
|
|
||||||
LogConfiguration::disable_logging();
|
LogConfiguration::disable_logging();
|
||||||
assert(Test_logconfiguration_subscribe_triggered == 3, "subscription not triggered (3)");
|
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 "
|
#define LOG_PREFIX_STR "THE_PREFIX "
|
||||||
|
@ -54,7 +54,7 @@ class LogStdoutOutput : public LogFileStreamOutput {
|
|||||||
private:
|
private:
|
||||||
static LogStdoutOutput _instance;
|
static LogStdoutOutput _instance;
|
||||||
LogStdoutOutput() : LogFileStreamOutput(stdout) {
|
LogStdoutOutput() : LogFileStreamOutput(stdout) {
|
||||||
set_config_string("all=off");
|
set_config_string("all=warning");
|
||||||
}
|
}
|
||||||
virtual bool initialize(const char* options, outputStream* errstream) {
|
virtual bool initialize(const char* options, outputStream* errstream) {
|
||||||
return false;
|
return false;
|
||||||
@ -70,7 +70,7 @@ class LogStderrOutput : public LogFileStreamOutput {
|
|||||||
private:
|
private:
|
||||||
static LogStderrOutput _instance;
|
static LogStderrOutput _instance;
|
||||||
LogStderrOutput() : LogFileStreamOutput(stderr) {
|
LogStderrOutput() : LogFileStreamOutput(stderr) {
|
||||||
set_config_string("all=warning");
|
set_config_string("all=off");
|
||||||
}
|
}
|
||||||
virtual bool initialize(const char* options, outputStream* errstream) {
|
virtual bool initialize(const char* options, outputStream* errstream) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -50,7 +50,7 @@ LogTagSet::LogTagSet(PrefixWriter prefix_writer, LogTagType t0, LogTagType t1, L
|
|||||||
_ntagsets++;
|
_ntagsets++;
|
||||||
|
|
||||||
// Set the default output to warning and error level for all new tagsets.
|
// 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) {
|
void LogTagSet::update_decorators(const LogDecorators& decorator) {
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user