# Worker API and logging

**URL:** <https://discuss.gradle.org/t/worker-api-and-logging/24559>\
**Category:** Help/Discuss\
**Created:** [October 27, 2017, 10:28pm UTC](https://discuss.gradle.org/t/worker-api-and-logging/24559 "2017-10-27T22:28:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DPUkyle](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/dpukyle/32/3671_2.png) [@DPUkyle](https://discuss.gradle.org/u/DPUkyle)\
**Post date:** [October 27, 2017, 10:28pm UTC](https://discuss.gradle.org/t/worker-api-and-logging/24559/1 "2017-10-27T22:28:51Z")

</div>

Hi everyone.

I’m very excited about the new Worker API, and I am converting a long-running task to operate in a separate process (`IsolationMode.PROCESS`). However, I have noticed that _all_ stdout of the action executed in the worker is echoed to the terminal, with no apparent API to control it. Is there a way to configure the log level?

Prior to the Worker API being released, I used a JavaExec task to accomplish something similar. In that case, I could wait for the exitcode of the JavaExec, then decide what I want to do with the stdout based on that. Here’s a simple example:

```
ByteArrayOutputStream stdout = new ByteArrayOutputStream();

ExecResult result = _project.javaexec(javaExecSpec -> {
  javaExecSpec.setMain("...")
  javaExecSpec.setStandardOutput(stdout);
});

int exitCode = result.getExitValue();

if(exitCode != 0 ) {
  LOGGER.quiet(stdout.toString()); //always log if there was a problem
} else {
  LOGGER.info(stdout.toString()); //only log if info-level logging or higher was requested
}

```

I hope this makes sense.

Thanks in advance,

Kyle

---

<div class="post-metadata">

**Author:** ![mkobit](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mkobit/32/7217_2.png) [@mkobit](https://discuss.gradle.org/u/mkobit)\
**Post date:** [May 13, 2019, 1:25pm UTC](https://discuss.gradle.org/t/worker-api-and-logging/24559/2 "2019-05-13T13:25:01Z")

</div>

I think [https://github.com/gradle/gradle/issues/2678](https://github.com/gradle/gradle/issues/2678) may be the issue you are looking for
