Redirecting both stdout and stderr to the same file
Kevin Yuan
farproc at gmail.com
Tue Dec 27 21:15:53 EST 2005
You should redirecte sys.stderr if you want to log error message.
saveout = sys.stdout
saveerr = sys.stderr
fsock = open('runtime.log', 'w')
sys.stdout = sys.stderr = fsock
2005/12/28, Randy Kreuziger <KREUZRSK at dfw.wa.gov>:
>
> Can stdout and stderr be redirected to the same file? I would like to
> redirect both to the same file but I'm not sure how to do it. Currenting
> I'm redirectiong stdout using the following code:
> saveout = sys.stdout
> fsock = open('runtime.log', 'w')
> sys.stdout = fsock
>
> The problem is that when en error occurs that my program was not written
> to handle that error message is being sent to the cmd window and not my log
> file. My program may simply need to be more robust however I'm still a
> python novice.
>
> Thanks
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051228/19695258/attachment.html>
More information about the Python-list
mailing list