Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import logging
- # Configure logging
- logging.basicConfig(filename='errors.txt', level=logging.ERROR, filemode='a')
- def separator():
- with open("errors.txt", "a") as file:
- file.write("\n*********\n\n")
- try:
- # Code that may raise an exception
- # ...
- x = 10 / 0 # Example division by zero error
- except Exception as e:
- logging.exception(str(e))
- separator()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement