I wanted to persist the data of Azure App Service with CosmosDB, so I added the ʻazure-cosmos` library with pip and implemented the connection process.
requirements.txt
azure-cosmos==4.0.0
After implementation, when debugging, I noticed a lot of logs about the Azure SDK package ʻazure.core.pipeline.policies.http_logging_policy`.
In this article, I will show you how to suppress the log output by changing the log level of the above logger.
In my environment, the following log was output.
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` You can suppress unnecessary logs by setting the log level in the logger.
application.py
logging.getLogger('azure.core.pipeline.policies.http_logging_policy').setLevel('WARNING')
In this example, logs of log level WARNING
or higher are output. If you want to set other logging levels, see logging — Logging facility for Python — Python 3.8.3 documentation (https://docs.python.org/3.8/library/logging.html#levels). ..
-[Quick Start: Build Python Apps Using Azure Cosmos DB SQL API Account | Microsoft Docs](https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api -python)
Recommended Posts