How to turn sqlalchemy logging off completely
Question:
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?
Answers:
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.
You can turn off the sqlalchemy
logger using:
import logging
logging.basicConfig()
logging.getLogger('sqlalchemy').setLevel(logging.ERROR)
For more info, see the docs.
A more drastic solution:
import logging
logging.disable(logging.WARNING)
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?
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.
You can turn off the sqlalchemy
logger using:
import logging
logging.basicConfig()
logging.getLogger('sqlalchemy').setLevel(logging.ERROR)
For more info, see the docs.
A more drastic solution:
import logging
logging.disable(logging.WARNING)