Skip to content

Commit bf4ee7f

Browse files
authored
[EventHub] Update README for enable logging section (#35955)
* [EventHub] Update README for enable logging section Adding an enable logging section like in [servicebus](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/servicebus/azure-servicebus/README.md#logging) as it's a common enough scenario to have on the readme. * typo * add in krista's suggestion
1 parent 697a9bf commit bf4ee7f

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

sdk/eventhub/azure-eventhub/README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,30 @@ Refer to [IoT Hub Connection String Sample](https://github.com/Azure/azure-sdk-f
408408

409409
## Troubleshooting
410410

411-
See the `azure-eventhubs` [troubleshooting guide](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventhub/azure-eventhub/TROUBLESHOOTING.md) for details on how to diagnose various failure scenarios.
411+
See the `azure-eventhub` [troubleshooting guide](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventhub/azure-eventhub/TROUBLESHOOTING.md) for details on how to diagnose various failure scenarios.
412+
413+
### Logging
414+
415+
- Enable `azure.eventhub` logger to collect traces from the library.
416+
- Enable AMQP frame level trace by setting `logging_enable=True` when creating the client.
417+
- Refer to [this guide](https://learn.microsoft.com/azure/developer/python/sdk/azure-sdk-logging) on configuring logging for Azure libraries for Python for additional information.
418+
419+
```python
420+
import logging
421+
import sys
422+
423+
handler = logging.StreamHandler(stream=sys.stdout)
424+
logger = logging.getLogger('azure.eventhub')
425+
logger.setLevel(logging.DEBUG)
426+
logger.addHandler(handler)
427+
428+
...
429+
430+
from azure.eventhub import EventHubProducerClient, EventHubConsumerClient
431+
432+
producer = EventHubProducerClient(..., logging_enable=True)
433+
consumer = EventHubConsumerClient(..., logging_enable=True)
434+
```
412435

413436
## Next steps
414437

0 commit comments

Comments
 (0)