How to use gzip on stdout

Does anyone know how I can use gzip to zip a large log file on the fly.
My simulation is currently logging a large file that I need for analysis at a later point. However the files are so huge that I may even run out of disk space. The content is mainly text so when compressed the files are smaller... I would like to gzip on the fly without having to dump it to a file and then create the archive.

This is what I am doing right now and would like to not store foo.log...

./sim <args> >foo.log 2>&1

tar -cf - foo.log | gzip > foo.tar.gz

Any suggetions?

Try:
./sim <args> 2>&1 | gzip >foo.gz

I think that works fine.. Thanks!