在python中开发Azure函数时忽略cosmosdb信息日志



我正在vscode上本地开发Azure功能,并使用Azure.cosmos模块查询一个遥远的cosmosdb。

我的问题是,对cosmosdb的每个查询都会在我的终端中生成信息(或详细(日志的日志,并使读取我自己的logging.info()输出变得非常困难。

我想隐藏的日志:

[2022-08-31T08:50:00.643Z] Request URL: 'https://xxx-norwayeast.documents.azure.com:443/dbs'
Request method: 'POST'
Request headers:
'Cache-Control': 'no-cache'
'x-ms-version': 'REDACTED'
'x-ms-documentdb-query-iscontinuationexpected': 'REDACTED'
'x-ms-consistency-level': 'REDACTED'
'x-ms-date': 'REDACTED'
'authorization': 'REDACTED'
'Content-Type': 'application/json'
'Accept': 'application/json'
'Content-Length': '12'
'User-Agent': 'azsdk-python-cosmos/4.2.0 Python/3.9.12 (Windows-10-10.0.25188-SP0)'
A body is sent with the request

我不知道如何设置日志级别以忽略cosmosdb日志(理想情况下只获取警告/错误日志(,或者在需要时只打印我自己的日志。

我的主机.json

{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
},
"extensions": {
"durableTask": {
"hubName": "%TaskHub%"
}
}
}

我的函数.json

{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "context",
"type": "orchestrationTrigger",
"direction": "in"
}
]
}

这需要在Azure功能上进行设置,您可以使用host.json

{
"version": "2.0",
"logging": {
"logLevel": {
"Function.YourFunctionName.User": "Information",
"Function": "Error"
}
}
}

最新更新