You generally do this from the command line. Not sure if this is the same with windows (doubtful) but under Linux (with BASH) you generally do
python foo.py > logfile.txt 2>&1
The `2>&1` bit redirects stderr into stdout, and the `> logfile.txt` bit redirects stdout into logfile.txt.
If you're writing to stderr from your Python program then you want to just set sys.stderr to sys.stdout at the top of your source file, which will effectively 'redirect' everything to STDOUT.