Python/logging

From Wiki
< Python
Revision as of 15:39, 14 December 2018 by Marcluer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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")