Print Standard Streams with Gradle


(Dan Levy) #1

Elasticsearch version: 6.2.1

Plugins installed: None

JVM version: 1.8.0

OS version: MacOS 10.13

I am trying to print standard streams System.out.print() when testing a bug fix. I found here that I can just add the following code to my build.gradle file in order to show standard streams:

apply plugin: 'java'

test {
    testLogging {
        outputs.upToDateWhen {false}
        showStandardStreams = true
    }
}

When I do this, I get the following build error when I run ./gradlew run in command line:

FAILURE: Build failed with an exception.

* Where:
Build file '.../elasticsearch/docs/build.gradle' line: 21

* What went wrong:
A problem occurred evaluating project ':docs'.
> Failed to apply plugin [id 'org.gradle.java']
   > Cannot add a SourceSet with name 'test' as a SourceSet with that name already exists.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 14s

What is the best way to print standard streams into the console?


(Dan Levy) #2

After reading through the gradle docs, I got some more information. The code I posted above does not need to be used. Here is the doc page on logging with Gradle.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.