Redirecting both stdout and stderr to the same file
farproc at gmail.com
Wed Dec 28 03:15:53 CET 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list