Created
January 24, 2018 06:58
-
-
Save harrifeng/c68dcf199ef5d1f02981f85e858b3553 to your computer and use it in GitHub Desktop.
This file contains 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 | |
from logging.handlers import RotatingFileHandler | |
log_formatter = logging.Formatter('%(asctime)s %(levelname)s %(funcName)s(%(lineno)d) %(message)s') | |
logFile = '/tmp/demo.log' | |
my_handler = RotatingFileHandler(logFile, mode='a', maxBytes=5*1024*1024, | |
backupCount=2, encoding=None, delay=0) | |
my_handler.setFormatter(log_formatter) | |
my_handler.setLevel(logging.INFO) | |
app_log = logging.getLogger('root') | |
app_log.setLevel(logging.INFO) | |
app_log.addHandler(my_handler) | |
while True: | |
app_log.info("data") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment