Created
May 13, 2021 04:29
-
-
Save Abhayparashar31/8b63b7156062c41f7f517ba43d3cf9cb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| import time | |
| from logging.handlers import TimedRotatingFileHandler | |
| logger = logging.getLogger(__name__) | |
| logger.setLevel(logging.DEBUG) | |
| ## Create a log file every seconds with a new log detail at the inteval of 2 | |
| handler = TimedRotatingFileHandler('app.log', when='s', interval=2, backupCount=3) | |
| logger.addHandler(handler) | |
| for i in range(20): | |
| logger.info(i) | |
| time.sleep(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment