I am running an python app in Windows 7 which uses sqlalchemy.
In the console (DOS prompt) I can see a lot of output from the sqlalchemy module e.g.
2013-09-16 13:59:20,158 INFO sqlalchemy.engine.base.Engine UPDATE DATA SET qty=?, price=?
I want to continue to log these messages in the log file but would like to suppress them from printing to the stdout.
Try adding a FileHandler
to the sqlalchemy
logger and setting its propagate
attribute to False
, for example like this:
import logging
sqla_logger = logging.getLogger('sqlalchemy')
sqla_logger.propagate = False
sqla_logger.addHandler(logging.FileHandler('/path/to/sqla.log'))
Alternatively you can use a logging configuration API (e.g. logging.config.dictConfig()
) to do the same thing as above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With