Skip to content

Instantly share code, notes, and snippets.

@marhar
Created August 26, 2015 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marhar/d85afa9d30a0f74bd481 to your computer and use it in GitHub Desktop.
Save marhar/d85afa9d30a0f74bd481 to your computer and use it in GitHub Desktop.
Python: rotating log file
import logging
import logging.handlers
logf = logging.getLogger('MyLogger')
logf.setLevel(logging.INFO)
handler = logging.handlers.RotatingFileHandler(
'logfile.txt', maxBytes=100*1000*1000, backupCount=5)
logf.addHandler(handler)
logf.info('this is a log message')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment