python如何打log

import glob 
import logging 
import logging.handlers 
LOG_FILENAME='logging_rotatingfile_example.out' 
# Set up a specific logger with our desired output level 
my_logger = logging.getLogger('MyLogger') 
my_logger.setLevel(logging.DEBUG) 
# Add the log message handler to the logger 
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, 
                                                maxBytes=20, 
                                                backupCount=5, 
                                            ) 
my_logger.addHandler(handler) 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章