try: # do something pass except: # this will print the message "An exception occurred and the traceback" # you can't have to explicitly give the message logger.exception("An exception occurred")