Skip to content

Commit ba3b1e3

Browse files
authored
Redirect testclusters ES process stdout/stderr to log file (#85349) (#85350)
Although most of the time the stdout and stderr of the Java process is not needed since ES has its own log file, there are some cases where it is very important to have the output before ES has initialized its logging system. This commit changes the stdout/stderr of the ES process created by testclusters to use the same log file that ES will write to. There should not be contention with ProcessBuilder and ES trying to write at the same time because ES swaps out the stream handles to write to its logging system, so after that point ProcessBuilder will never see anymore output. relates #68333
1 parent 2c174a1 commit ba3b1e3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,9 +906,10 @@ private void startElasticsearchProcess() {
906906
environment.clear();
907907
environment.putAll(getESEnvironment());
908908

909-
// Just toss the output since we rely on the normal log file written by Elasticsearch
910-
processBuilder.redirectOutput(ProcessBuilder.Redirect.DISCARD);
911-
processBuilder.redirectError(ProcessBuilder.Redirect.DISCARD);
909+
// Direct the stdout and stderr to the ES log file. This should not contend with the actual ES
910+
// process once it is started since there we close replace stdout/stderr handles once logging is setup.
911+
processBuilder.redirectOutput(ProcessBuilder.Redirect.appendTo(esLogFile.toFile()));
912+
processBuilder.redirectErrorStream(true);
912913

913914
if (keystorePassword != null && keystorePassword.length() > 0) {
914915
try {

0 commit comments

Comments
 (0)