Skip to content

Instantly share code, notes, and snippets.

@Abhayparashar31
Created May 13, 2021 04:29
Show Gist options
  • Save Abhayparashar31/8b63b7156062c41f7f517ba43d3cf9cb to your computer and use it in GitHub Desktop.
Save Abhayparashar31/8b63b7156062c41f7f517ba43d3cf9cb to your computer and use it in GitHub Desktop.
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