Azure-sdk-for-python: How to disable HTTP logging?

Created on 13 Jan 2020  路  3Comments  路  Source: Azure/azure-sdk-for-python

  • Package Name: azure-storage
  • Package Version: 12.1.0
  • Operating System: Ubuntu 18.04
  • Python Version: 3.6.8

Describe the bug
It's unclear to me how I can disable the default HTTP logging policy. Is this documented somewhere?

Client Storage

Most helpful comment

Hi @Korijn
This logger respects the logging protocol of Python, and the logger itself is named azure.core.pipeline.policies.http_logging_policy. You can change the level of this level to WARNING for instance.

Reference:
https://docs.python.org/3.8/library/logging.html

All 3 comments

Hi @Korijn
This logger respects the logging protocol of Python, and the logger itself is named azure.core.pipeline.policies.http_logging_policy. You can change the level of this level to WARNING for instance.

Reference:
https://docs.python.org/3.8/library/logging.html

Ok, thanks! I ended up setting logger.disable = True on that logger to avoid a little more overhead

Hello everyone,

Certainly, setting the logger level to WARNING solves the problem:

logger = logging.getLogger("azure.core.pipeline.policies.http_logging_policy")
logger.setLevel(logging.WARNING)

However, it seems that Cosmos DB client does not respect logging_enable constructor parameter mentioned in the documentation:
https://docs.microsoft.com/en-us/python/api/overview/azure/cosmos-readme?view=azure-python#logging
It is not possible to disable logging by setting it to False:

# doesn't work
client = CosmosClient(url, credential=key, logging_enable=False)

I'm using azure-cosmos 4.2.0.

Thanks for your support.
Sergey

Was this page helpful?
0 / 5 - 0 ratings