diff --git a/sdk/core/Azure.Core/samples/Diagnostics.md b/sdk/core/Azure.Core/samples/Diagnostics.md index 9d0df195ba4a..be45af4bce9f 100644 --- a/sdk/core/Azure.Core/samples/Diagnostics.md +++ b/sdk/core/Azure.Core/samples/Diagnostics.md @@ -9,13 +9,17 @@ Azure SDKs produce various log messages that include information about: 2. Authentication attempts 3. Retries -The simplest way to see the logs is to enable the console logging. +The simplest way to see the logs is to enable the console logging using the [`AzureEventSourceListener`](https://docs.microsoft.com/dotnet/api/azure.core.diagnostics.azureeventsourcelistener?view=azure-dotnet). ```C# Snippet:ConsoleLogging // Setup a listener to monitor logged events. using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger(); ``` +### Azure Event Source Listener lifetime + +In order for the `AzureEventSourceListener` to collect logs, it must be in scope and active while the client library is in use. If the listener is disposed or otherwise out of scope, logs cannot be collected. Generally, we recommend creating the listener as a top-level member of the class where the Event Hubs client being inspected is used. + ### Enabling content logging By default only URI and headers are logged. To enable content logging, set the `Diagnostics.IsLoggingContentEnabled` client option: