Skip to content

Commit fbe7cf7

Browse files
authored
Redirect testclusters ES process stdout/stderr to log file (#85349) (#85354)
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 b7aa27a commit fbe7cf7

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
@@ -917,9 +917,10 @@ private void startElasticsearchProcess() {
917917
environment.clear();
918918
environment.putAll(getESEnvironment());
919919

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

924925
if (keystorePassword != null && keystorePassword.length() > 0) {
925926
try {

0 commit comments

Comments
 (0)