Ich wollte die Azure App Service-Daten mit CosmosDB persistent machen, also habe ich die Bibliothek "azure-cosmos" mit pip hinzugefügt und den Verbindungsprozess implementiert.
requirements.txt
azure-cosmos==4.0.0
Nach der Implementierung habe ich beim Debuggen viele Protokolle zum Azure SDK-Paket "azure.core.pipeline.policies.http_logging_policy" festgestellt.
In diesem Artikel werde ich Ihnen zeigen, wie Sie die Protokollausgabe unterdrücken, indem Sie die Protokollstufe des obigen Protokollierers ändern.
In meiner Umgebung wurde das folgende Protokoll ausgegeben.
2020-06-24 19:11:55,493 DEBUG urllib3.connectionpool :https://xxx.documents.azure.com:443 "POST /dbs/xxx/colls/xxx/docs/ HTTP/1.1" 200 None
2020-06-24 19:11:55,495 INFO azure.core.pipeline.policies.http_logging_policy :Response status: 200
2020-06-24 19:11:55,495 INFO azure.core.pipeline.policies.http_logging_policy :Response headers:
2020-06-24 19:11:55,495 INFO azure.core.pipeline.policies.http_logging_policy : 'Cache-Control': 'no-store, no-cache'
2020-06-24 19:11:55,495 INFO azure.core.pipeline.policies.http_logging_policy : 'Pragma': 'no-cache'
2020-06-24 19:11:55,495 INFO azure.core.pipeline.policies.http_logging_policy : 'Transfer-Encoding': 'chunked'
2020-06-24 19:11:55,495 INFO azure.core.pipeline.policies.http_logging_policy : 'Content-Type': 'application/json'
2020-06-24 19:11:55,495 INFO azure.core.pipeline.policies.http_logging_policy : 'Server': 'Microsoft-HTTPAPI/2.0'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'Strict-Transport-Security': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-last-state-change-utc': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-resource-quota': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-resource-usage': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'lsn': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-item-count': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-schemaversion': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-alt-content-path': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-content-path': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-quorum-acked-lsn': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-current-write-quorum': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-current-replica-set-size': 'REDACTED'
2020-06-24 19:11:55,496 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-xp-role': 'REDACTED'
2020-06-24 19:11:55,497 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-cosmos-query-execution-info': 'REDACTED'
2020-06-24 19:11:55,497 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-global-Committed-lsn': 'REDACTED'
2020-06-24 19:11:55,497 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-number-of-read-regions': 'REDACTED'
2020-06-24 19:11:55,497 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-transport-request-id': 'REDACTED'
2020-06-24 19:11:55,497 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-cosmos-llsn': 'REDACTED'
2020-06-24 19:11:55,497 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-cosmos-quorum-acked-llsn': 'REDACTED'
2020-06-24 19:11:55,497 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-session-token': 'REDACTED'
2020-06-24 19:11:55,498 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-request-charge': 'REDACTED'
2020-06-24 19:11:55,498 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-serviceversion': 'REDACTED'
2020-06-24 19:11:55,498 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-activity-id': 'REDACTED'
2020-06-24 19:11:55,498 INFO azure.core.pipeline.policies.http_logging_policy : 'x-ms-gatewayversion': 'REDACTED'
2020-06-24 19:11:55,498 INFO azure.core.pipeline.policies.http_logging_policy : 'Date': 'Wed, 24 Jun 2020 10:11:55 GMT'
azure.core.pipeline.policies.http_logging_policy
Sie können unnötige Protokolle unterdrücken, indem Sie die Protokollstufe im Logger festlegen.
application.py
logging.getLogger('azure.core.pipeline.policies.http_logging_policy').setLevel('WARNING')
In diesem Beispiel werden Protokolle der Protokollebene "WARNING" oder höher ausgegeben. Wenn Sie andere Protokollierungsstufen festlegen möchten, lesen Sie die Dokumentation Protokollierung - Protokollierungsfunktion für Python - Python 3.8.3 (https://docs.python.org/3.8/library/logging.html#levels). ..
Recommended Posts