Use the python protocol library. To log exceptions, you need to use try and except blocks.
import logging logging.basicConfig(filename='log.txt', format=logging.BASIC_FORMAT) logging.error('OH NO!') try: raise Exception('Foo') except: logging.exception("Oops:")
The contents of log.txt :
ERROR:root:OH NO!
You can add many different registrars that go to different places, have different names or use different formats. However, the Python protocol library is what you want.
source share