Created
August 26, 2015 05:08
-
-
Save marhar/d85afa9d30a0f74bd481 to your computer and use it in GitHub Desktop.
Python: rotating log file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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