# Redirect STDOUT for Rake?

**URL:** <https://www.ruby-forum.com/t/redirect-stdout-for-rake/115112>\
**Category:** Rails\
**Created:** [September 20, 2007, 6:51pm UTC](https://www.ruby-forum.com/t/redirect-stdout-for-rake/115112 "2007-09-20T18:51:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [September 20, 2007, 6:51pm UTC](https://www.ruby-forum.com/t/redirect-stdout-for-rake/115112/1 "2007-09-20T18:51:58Z")

</div>

Hi,

I’m trying to capture the output of my rake tasks/tests and can’t seem  
to get this working. At the top of my Rake file I’ve got:

$stdout = StringIO.new

I also put it after loading ‘rake/testtask’ but I get the same thing,  
which is Rake is seemingly un-altered. The output stil goes straight  
to the console. How can I capture this output into my own IO objects?

Thanks,  
Matt
