I am writting a daemon server using python, sometimes there are python runtime errors, for example some variable type is not correct. That error will not cause the process to exit.
Is it possible for me to redirect such runtime error to a log file?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It looks like you are asking two questions.
To prevent your process from exiting on errors, you need to catch all
exceptions that are raised usingtry...except...finally.You also wish to redirect all output to a log. Happily, Python provides a comprehensive
loggingmodule for your convenience.An example, for your delight and delectation:
This graciously emits: