You may have a main function and a log in case the main function works
def main(): ... raise ValueError("crashed because I'm a bad exception") ... if __name__ == "__main__": try: main() except Exception as e: logger.exception("main crashed. Error: %s", e)
This is better if you use something like logstash and want to see the error and time of your user interface.
Thanks Eric for improving the answer
Ahmed source share