问题
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