Redirecting Error Information : stdout stderr « Development « Python






Redirecting Error Information



import sys 

fsock = open('error.log', 'w')                         
sys.stderr = fsock                                     
raise Exception, 'this error will be logged'           
           
       








Related examples in the same category

1.Use system function to outputUse system function to output
2.Different way to output string: print and sys.stdout.writeDifferent way to output string: print and sys.stdout.write
3.Introducing stdout and stderrIntroducing stdout and stderr
4.Redirecting stdout and stderr OutputRedirecting stdout and stderr Output
5.Printing to stderrPrinting to stderr