sqlalchemy.log.InstanceLogger.__init__
中向他们的记录器添加了自己的处理程序。 def __init__(self, echo: _EchoFlagType, name: str):
self.echo = echo
self.logger = logging.getLogger(name)
# if echo flag is enabled and no handlers,
# add a handler to the list
if self._echo_map[echo] <= logging.INFO and not self.logger.handlers:
_add_default_handler(self.logger) # <=== Handler is added here
logging.basicConfig()
的行为。from sqlalchemy import log as sqlalchemy_log
sqlalchemy_log._add_default_handler = lambda x: None # Patch to avoid duplicate logging