I have an application which is using azure.storage.blob python module.
Evidently, when I am executing it, the module is dumping its log data in the logger which I dont want because it is large and my own application info gets lost in between it.
Is there any way to remove the logger from azure.storage.blob python module?
log sample:
INFO:azure.storage.common.storageclient:Client-Request-ID=d5afebc0-aa84-11e8-be16-000d3ae070ae Outgoing request: Method=PUT, Path=/marketingcloud-raw-events/2018/8/27/bounce.csv, Query={'timeout': None}, Headers={'Content-Length': '38176', 'x-ms-blob-type': 'BlockBlob', 'x-ms-version': '2018-03-28', 'x-ms-lease-id': None, 'x-ms-client-request-id': 'd5afebc0-aa84-11e8-be16-000d3ae070ae', 'If-Match': None, 'If-Modified-Since': None, 'If-None-Match': None, 'User-Agent': 'Azure-Storage/1.3.0-1.3.1 (Python CPython 2.7.15; Linux 4.15.0-1021-azure)'
In there select App Service logs. Switch On Application Logging (Blob), set Level to Information, Retention Period to 1 and then click on Storage Settings. In the next window select our blob storage account and create a container.
This logging allows you to monitor I/O requests and responses that client libraries are making to Azure services. Typically, the logs are used to debug or diagnose communication issues. This article describes the following approaches to enable logging with the Azure SDK for .NET:
Content logging is disabled by default. To enable it, see Log HTTP request and response bodies. The Azure SDK for .NET's client libraries log events to Event Tracing for Windows (ETW) via the System.Diagnostics.Tracing.EventSource class, which is typical for .NET.
All storage log messages are subsequently directed to the console. The following sample Java code shows how to switch storage client logging off by default by calling the static method setLoggingEnabledByDefault, and then use an OperationContext object to enable logging for a specific request:
This is actually very easy to do. You can adjust any logger.
Just do this near the start of your program to switch verbosity from INFO to WARNING, or whatever you prefer.
logging.getLogger("azure.storage.common.storageclient").setLevel(logging.WARNING)
Some messages are related to http calls. Also try the following:
logger=logging.getLogger('azure.core.pipeline.policies.http_logging_policy')
logger.setLevel(logging.WARNING)
I had the same issue that the azure blob API was spamming my log stream.
When you build a BlobClient
you can also pass a custom logger which you can control as you like.
logger = logging.getLogger("logger_name")
logger.disabled = True
my_blob_client = BlobClient.from_connection_string("azure blob connection string", container_name="container", blob_name="blob", logger=logger)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With