Answer the question
In order to leave comments, you need to log in
How to redirect error output in python?
I have a python3 script which I am running on linux. Sometimes this script throws a bunch of errors and exceptions. I want all error and exception messages to be written to a file and the output of the script to remain clean. To do this, I do this:
myscript.py 2> errors.log
But I don't want to write "2> errors.log" every time, I want the script itself to be able to redirect the stream with errors.
Answer the question
In order to leave comments, you need to log in
Wrap the program start in a shell script - it suggests itself in the first place.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question