Skip to content

Commit 972177f

Browse files
committed
add examples for enabling debug level logs
1 parent 4a6b3f6 commit 972177f

File tree

2 files changed

+41
-23
lines changed

2 files changed

+41
-23
lines changed

articles/azure-app-configuration/enable-dynamic-configuration-aspnet-core.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,25 @@ Logs are output upon configuration refresh and contain detailed information on k
244244
| Warning | Logs include failures and exceptions that occurred during configuration refresh. Occasional occurrences can be ignored because the configuration provider library will continue to use the cached data and attempt to refresh the configuration next time. You can monitor logs at this level for repetitive warnings that may indicate potential issues. For example, you rotated the connection string but forgot to update your application. |
245245
- The logging category is `Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh`, which appears before each log.
246246
- Here are some example logs at each log level:
247-
```console
248-
dbug: Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh[0]
249-
Key-value read from App Configuration. Change:'Modified' Key:'ExampleKey' Label:'ExampleLabel' Endpoint:'https://examplestore.azconfig.io'
247+
```console
248+
dbug: Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh[0]
249+
Key-value read from App Configuration. Change:'Modified' Key:'ExampleKey' Label:'ExampleLabel' Endpoint:'https://examplestore.azconfig.io'
250250
251-
info: Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh[0]
252-
Setting updated. Key:'ExampleKey'
251+
info: Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh[0]
252+
Setting updated. Key:'ExampleKey'
253253

254-
warn: Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh[0]
255-
A refresh operation failed.
256-
Service request failed.
257-
```
254+
warn: Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh[0]
255+
A refresh operation failed.
256+
Service request failed.
257+
```
258+
- You can enable logging at the `Debug` log level by adding the following example to your `appsettings.json` file. This applies to all other log levels as well.
259+
```json
260+
"Logging": {
261+
"LogLevel": {
262+
"Microsoft.Extensions.Configuration.AzureAppConfiguration": "Debug"
263+
}
264+
}
265+
```
258266

259267
Using `ILogger` is the preferred method and is prioritized as the logging source if an instance of `ILoggerFactory` is present. However, if `ILoggerFactory` is not available, logs can alternatively be enabled and configured through the [instructions for .NET Core apps](./enable-dynamic-configuration-dotnet-core.md#monitoring-and-troubleshooting). For more information on how to utilize these logs, follow the instructions for [logging in .NET Core and ASP.NET Core](/aspnet/core/fundamentals/logging).
260268

articles/azure-app-configuration/enable-dynamic-configuration-dotnet-core.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,26 +144,36 @@ Calling the `ConfigureRefresh` method alone won't cause the configuration to ref
144144

145145
Logs are output upon configuration refresh and contain detailed information on key-values retrieved from your App Configuration store and configuration changes made to your application. You can enable these logs using the instructions for [logging with the Azure SDK for .NET](/dotnet/azure/sdk/logging).
146146

147-
- Logs are output at different log levels. The default level is `Informational`.
147+
- Logs are output at different event levels. The default level is `Informational`.
148148

149-
| Log Level | Description |
149+
| Event Level | Description |
150150
|---|---|
151151
| Verbose | Logs include the key and label of key-values your application monitors for changes from your App Configuration store. The information also includes whether the key-value has changed compared with what your application has already loaded. Enable logs at this level to troubleshoot your application if a configuration change didn't happen as expected. |
152152
| Informational | Logs include the keys of configuration settings updated during a configuration refresh. Values of configuration settings are omitted from the log to avoid leaking sensitive data. You can monitor logs at this level to ensure your application picks up expected configuration changes. |
153153
| Warning | Logs include failures and exceptions that occurred during configuration refresh. Occasional occurrences can be ignored because the configuration provider library will continue to use the cached data and attempt to refresh the configuration next time. You can monitor logs at this level for repetitive warnings that may indicate potential issues. For example, you rotated the connection string but forgot to update your application. |
154154
- The logging category is `Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh`, which appears before each log.
155-
- Here are some example logs at each log level:
156-
```console
157-
[Verbose] Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh:
158-
Key-value read from App Configuration. Change:'Modified' Key:'ExampleKey' Label:'ExampleLabel' Endpoint:'https://examplestore.azconfig.io'
159-
160-
[Informational] Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh:
161-
Setting updated. Key:'ExampleKey'
162-
163-
[Warning] Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh:
164-
A refresh operation failed.
165-
Service request failed.
166-
```
155+
- Here are some example logs at each event level:
156+
```console
157+
[Verbose] Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh:
158+
Key-value read from App Configuration. Change:'Modified' Key:'ExampleKey' Label:'ExampleLabel' Endpoint:'https://examplestore.azconfig.io'
159+
160+
[Informational] Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh:
161+
Setting updated. Key:'ExampleKey'
162+
163+
[Warning] Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh:
164+
A refresh operation failed.
165+
Service request failed.
166+
```
167+
- You can enable logging at the `Verbose` event level by specifying the `EventLevel.Verbose` parameter, as done in the following example. This applies to all other event levels as well. This example also enables logs for only the `Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh` category.
168+
```csharp
169+
using var listener = new AzureEventSourceListener((eventData, text) =>
170+
{
171+
if (eventData.EventSource.Name == "Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh")
172+
{
173+
Console.WriteLine("[{1}] {0}: {2}", eventData.EventSource.Name, eventData.Level, text);
174+
}
175+
}, EventLevel.Verbose);
176+
```
167177

168178
## Clean up resources
169179

0 commit comments

Comments
 (0)