save the error log into a file and sen email python code example
Example: outputting file logs into text in python
import logging
logging.basicConfig(filename='app.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s')
logging.warning('This will get logged to a file')