蓝图访问应用程序记录器的标准方法是什么?
答案 0 :(得分:71)
添加:
from flask import current_app
并在需要时致电:
current_app.logger.info('grolsh')
答案 1 :(得分:10)
# core.py
from werkzeug.local import LocalProxy
from flask import current_app
logger = LocalProxy(lambda: current_app.logger)
# views.py
from core import logger
@mod.route("/")
def index():
logger.info("serving index")
...