我自己写了个 记录日志的
def register_logger(app): log_dict = { 'INFO': logging.INFO, 'DEBUG': logging.DEBUG, 'ERROR': logging.ERROR, 'WARNING': logging.WARNING } file_handler = logging.FileHandler('log/flask.log') file_handler.setLevel(log_dict[app.config['LEVEL']]) if app.config['LEVEL'] else file_handler.setLevel(logging.INFO) logging_format = logging.Formatter( '[%(asctime)s] %(levelname)s in %(filename)s - %(funcName)s [line:%(lineno)d]: %(message)s') file_handler.setFormatter(logging_format) app.logger.addHandler(file_handler)
日志文件放在哪层比较好