Skip to content

Commit f4c3658

Browse files
authored
[Azure.Core] Logging Sample Enhancement (Azure#25389)
# Summary The focus of these changes is to enhance the logging section of the diagnostics sample to include details about the lifetime of the `AzureEventSourceListener`. We received some customer feedback that it was unclear where they needed to create the listener and that it had to have the appropriate scope to be able to capture logs.
1 parent c19c810 commit f4c3658

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sdk/core/Azure.Core/samples/Diagnostics.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ Azure SDKs produce various log messages that include information about:
99
2. Authentication attempts
1010
3. Retries
1111

12-
The simplest way to see the logs is to enable the console logging.
12+
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).
1313

1414
```C# Snippet:ConsoleLogging
1515
// Setup a listener to monitor logged events.
1616
using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger();
1717
```
1818

19+
### Azure Event Source Listener lifetime
20+
21+
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.
22+
1923
### Enabling content logging
2024

2125
By default only URI and headers are logged. To enable content logging, set the `Diagnostics.IsLoggingContentEnabled` client option:

0 commit comments

Comments
 (0)