我的情况是,我有一个调用 logging.debug(xxx) 的包。我想禁用这个包的所有日志记录语句。有没有办法通过配置做到这一点?
例如,我运行的每个查询都在开发服务器的控制台中打印出来:
调试:根:选择实体。路径,Entities.entity FROM "dev~xxxx!!Entities" AS Entities INNER JOIN "dev~xxxx!!EntitiesByProperty" AS ebp_0 ON Entities。路径= ebp_0。路径INNER JOIN "dev~xxxx!!EntitiesByProperty" AS ebp_1 ON Entities。路径= ebp_1。路径INNER JOIN "dev~xxxx!!EntitiesByProperty" AS ebp_2 ON Entities。路径= ebp_2。路径在哪里 ebp_0.kind = :1 AND ebp_0.name = :2 AND ebp_0.value = :3 AND ebp_1.kind = :4 AND ebp_1.name = :5 AND ebp_1.value = :6 AND ebp_2.kind = :7 AND ebp_2.name = :8 AND ebp_2.value = :9 按实体排序。路径ASC
所以我知道如何通过修改sdk源来禁用它,基本上注释掉里面的日志语句__StarSchemaQueryPlan
logging.debug(query)
有没有办法在不接触 SDK 代码的情况下禁用日志记录?我们目前没有定义任何 loggingConfigurations,而是使用 basicConfiguror。
最终解决方案谢谢@lucemia:
class Filter(object):
def filter(self, record):
if record.funcName=='__StarSchemaQueryPlan' and record.module=='datastore_sqlite_stub':
return 0
else:
return 1