Link Python system error stream into a file : Standard Redirect « Development « Python






Link Python system error stream into a file


import sys

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

           
       








Related examples in the same category

1.Link Python print stream into a fileLink Python print stream into a file
2.Log print message into a fileLog print message into a file
3.Map string to sys.stout.writeMap string to sys.stout.write
4.Redirects prints to file