import logging logger = logging.getLogger(‘mylogger‘) logger.setLevel(logging.INFO) fh=logging.handlers.RotatingFileHandler(‘/tmp/test.log‘, mode = ‘a‘, maxBytes=10240, backupCount=3, encoding=‘utf-8‘) formatter = logging.Formatter(‘%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s - %(message)s‘) fh.setFormatter(formatter) logger.addHandler(fh) logger.info(‘hello logging‘) logger.warning(‘hello logging‘) logger.error(‘hello logging‘) logger.critical(‘hello logging‘)
import logging import logging.handlers ……重新运行,程序正常输出。
AttributeError: 'module' object has no attribute 'handlers'--Python子模块导入问题,布布扣,bubuko.com
AttributeError: 'module' object has no attribute 'handlers'--Python子模块导入问题
原文:http://blog.csdn.net/zyz511919766/article/details/25216585