5
votes

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)'

4
Can you share some sample logging ? also some code ? Which method are you using ?Thomas
I am getting something like these: 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)',Gagan
if you look at this file (from github repo) github.com/Azure/azure-storage-python/blob/master/…, it seems you cant disable the logger. You can create a new issue to get this change doneThomas
Hi,any updates now?Jay Gong

4 Answers

1
votes

As Thomas mentioned in the comment, you could find the code of log data is encapsulated in the azure.storage.blob python sdk. As I know, there's no such switch to close this logging mechanism.

1.You can encapsulate the SDK by yourself and get rid of these redundant logs.

2.Or you just could try to add special tags to the application logs and filter out redundant other log data.

3.You could commit feedback to azure to make the the log data as optional.

Hope it helps you.

24
votes

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)
2
votes

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)
0
votes

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)