将模块记录器配置为应用程序记录器 [英] Configure module logger to flask app logger

查看:138
本文介绍了将模块记录器配置为应用程序记录器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 导入日志记录
logger =日志记录。 getLogger(XYZ)
...
logger.debug(stuff)

不需要修改模块中的任何东西,我可以配置烧瓶,使模块在调用getLogger(XYZ)的时候得到烧瓶的app.logger吗?



默认情况下,烧瓶记录器的名字是你的应用程序的名称,但烧瓶有设置 LOGGER_NAME


My flask application uses a module which gets a logger like this:

import logging
logger = logging.getLogger("XYZ")
...
logger.debug("stuff")

Without having to modify anything in the module, can I configure flask such that the module will get flask's app.logger when it makes the getLogger("XYZ") call?

解决方案

Yes, you can configure it.

By default flask logger's name is your app name, but flask has setting LOGGER_NAME.

这篇关于将模块记录器配置为应用程序记录器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆