You seem to be asking two questions.
So that your process does not depend on errors, you need to catch all exceptionthat were raised with try...except...finally.
You also want to redirect all output to the log. Fortunately, Python provides a comprehensive loggingmodule for your convenience.
Example, for your pleasure and admiration:
import logging
logging.basicConfig(filename='warning.log', level=logging.WARNING)
try:
1/0
except ZeroDivisionError, e:
logging.warning('The following error occurred, yet I shall carry on regardless: %s', e)
This kindly emits:
% cat warning.log
WARNING:root:The following error occurred, yet I shall carry on regardless: integer division or modulo by zero