flask logging 不及时写入日志文件
handler = logging.FileHandler('flask.log', encoding='UTF-8')
handler.setLevel(logging.DEBUG)
logging_format = logging.Formatter(
'%(asctime)s - %(levelname)s - %(filename)s - %(funcName)s - %(lineno)s - %(message)s')
handler.setFormatter(logging_format)
app.logger.addHandler(handler)
current_app.logger.debug('A value for debugging')
current_app.logger.warning('A warning occurred (%d apples)', 42)
current_app.logger.error('An error occurred')
即时写入log文件,好查看错误,现在是关闭或重启才能写入到log文件中
慕田峪9158850
相关分类