How to turn sqlalchemy logging off completely

空扰寡人 提交于 2020-05-12 11:22:05

问题


sqlalchemy is keep loggin to console even I have the following code

import logging
logger = logging.getLogger()
logger.disabled = True

How to turn off sqlalchemy's logging completely?


回答1:


Did you pass echo=True to create_engine()? By default it creates StreamHandler which outputs to console. As documentation says, if you didn't provide any echo=True arguments and didn't configure root sqlalchemy logger, it will not log anything.




回答2:


You can turn off the sqlalchemy logger using:

import logging

logging.basicConfig()
logging.getLogger('sqlalchemy').setLevel(logging.ERROR)

For more info, see the docs.



来源:https://stackoverflow.com/questions/18900888/how-to-turn-sqlalchemy-logging-off-completely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!