Created
August 25, 2022 10:42
-
-
Save k12ish/8695dd73e5a0ff6dfb5786e8c4df2780 to your computer and use it in GitHub Desktop.
Python Logging Boilerplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from logging.handlers import RotatingFileHandler | |
file_handler = RotatingFileHandler("my_log.log", backupCount=5) | |
file_handler.doRollover() | |
logging.basicConfig( | |
level=logging.INFO, | |
format="%(asctime)s [%(levelname)s] %(message)s", | |
handlers=[ | |
file_handler, | |
logging.StreamHandler(), | |
], | |
) | |
logging.info("Started log.py") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment