# How to Capture STDOUT for esrally?

**URL:** <https://discuss.elastic.co/t/how-to-capture-stdout-for-esrally/175942>\
**Category:** Elasticsearch\
**Tags:** rally\
**Created:** [April 9, 2019, 3:28am UTC](https://discuss.elastic.co/t/how-to-capture-stdout-for-esrally/175942 "2019-04-09T03:28:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rocksnslopes](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@rocksnslopes](https://discuss.elastic.co/u/rocksnslopes)\
**Post date:** [April 9, 2019, 3:28am UTC](https://discuss.elastic.co/t/how-to-capture-stdout-for-esrally/175942/1 "2019-04-09T03:28:21Z")

</div>

Attempting to run esrally commands as a Jenkins job using a docker container. I simply want to see the output printed out in the Jenkins console. For simple commands like "esrally --version" or "esrally --help" this works fine. When invoking a subcommand like "esrally list tracks" or ultimately running a race, there is no output.

Taking Jenkins out of the picture, I tried to simply redirect to a file and as expected the following worked:

esrally --version \> output.txt  
esrally --help \> output.txt

But the following produced only empty files:

esrally list tracks \> output.txt

So it appears when invoking subcommands, the output is not actually going to stdout? Is there a way around this? I know of the --report-file option, but that only works if the command is successful only when running a track, and will not produce a report for subcommands or if the track fails.

Appreciate any help if anyone has experienced something similar.

Thanks!

---

<div class="post-metadata">

**Author:** ![rocksnslopes](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@rocksnslopes](https://discuss.elastic.co/u/rocksnslopes)\
**Post date:** [April 9, 2019, 4:50pm UTC](https://discuss.elastic.co/t/how-to-capture-stdout-for-esrally/175942/2 "2019-04-09T16:50:40Z")

</div>

I think I found the issue.

Removed the check for isatty() in esrally/utils/console.py and can now redirect to a file. Not sure of the repercussions though.

def println(msg, console\_prefix=None, end="\n", flush=False, logger=None, overline=None, underline=None):  
# TODO: Checking for sys.stdout.isatty() prevents shell redirections and pipes (useful for list commands). Can we remove this check?  
if not QUIET and **sys.stdout.isatty()**:  
complete\_msg = "%s %s" % (console\_prefix, msg) if console\_prefix else msg  
if overline:  
print(format.underline\_for(complete\_msg, underline\_symbol=overline), flush=flush)  
print(complete\_msg, end=end, flush=flush)  
if underline:  
print(format.underline\_for(complete\_msg, underline\_symbol=underline), flush=flush)  
if logger:  
logger(msg)

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [April 10, 2019, 2:00pm UTC](https://discuss.elastic.co/t/how-to-capture-stdout-for-esrally/175942/3 "2019-04-10T14:00:49Z")

</div>

Hi,

I have raised [https://github.com/elastic/rally/pull/677](https://github.com/elastic/rally/pull/677) which will allow you to redirect Rally's command line output as long as the Rally daemon is not involved (it does not seem to be in your case), i.e. what you're describing should be possible with the next version (1.1.0) of Rally.

Daniel

---

<div class="post-metadata">

**Author:** ![rocksnslopes](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@rocksnslopes](https://discuss.elastic.co/u/rocksnslopes)\
**Post date:** [April 11, 2019, 6:16am UTC](https://discuss.elastic.co/t/how-to-capture-stdout-for-esrally/175942/4 "2019-04-11T06:16:17Z")

</div>

Thank you Daniel

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 9, 2019, 6:16am UTC](https://discuss.elastic.co/t/how-to-capture-stdout-for-esrally/175942/5 "2019-05-09T06:16:28Z")

</div>

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