how to log all console output to a file python code example Example: redirect python output to file $ python foo.py > file