Skip to content

Instantly share code, notes, and snippets.

@tsileo
Created November 5, 2012 16:11
Show Gist options
  • Save tsileo/4018031 to your computer and use it in GitHub Desktop.
Save tsileo/4018031 to your computer and use it in GitHub Desktop.
RotatingFileHandler
import logging
LOG_FILENAME = '/tmp/mongodb_backups.log'
# Set up a specific logger with our desired output level
logger = logging.getLogger('dico')
logger.setLevel(logging.DEBUG)
# Add the log message handler to the logger
handler = logging.handlers.RotatingFileHandler(
LOG_FILENAME, backupCount=3, maxBytes=10000000)
handler.setFormatter(logging.Formatter("%(asctime)s;%(levelname)s;%(message)s",
"%Y-%m-%d %H:%M:%S"))
logger.addHandler(handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment