Python/logging

From Wiki

Basic with rotation

import logging
import logging.handlers

LOG_FILENAME = 'StatusLight.log'
log = logging.getLogger('log')
log.setLevel(logging.INFO)
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=5*1024*1024, backupCount=5)
log.addHandler(handler)

log.info("hello")