diff --git a/README.md b/README.md index 936ef5d..843d48d 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ source.ClearKeyTransformers(); ### Refreshing secrets -By default, secrets are not refreshed. In order to enable refreshing, you can configure `ConfigurationWatcher` property: +By default, secrets are not refreshed. In order to enable refreshing, you can set configuration watcher: ```csharp // implements `IConfigurationWatcher` @@ -200,7 +200,8 @@ For more details about _Options pattern_, see official documentation [Options pa Please note that there is associated cost of retrieving secret values from AWS Secrets Manager. Refer to the [AWS Secrets Manager pricing](https://aws.amazon.com/secrets-manager/pricing/) for further information. -Watcher is started **ONLY** when initial load is successful. +> [!IMPORTANT] +> Watcher is started **ONLY** when initial load is successful. ### Preventing hangs @@ -264,6 +265,28 @@ By default, logging is disabled (by using `NullLoggerFactory`). Since logging happens during the host build phase (before the application is fully built), it's not possible to use the final application logger. Perhaps you will need to configure logging twice - once for the provider and once for the application. +#### Reusing application logger + +If your logger requires more complex configuration you don't want to repeat (in configuration phase), +it's possible to pass `ILoggerFactory` instance to the provider retrospectively: + +```csharp +public static WebApplication UseAppLoggerInSecretsManagerConfigProvider(this WebApplication app) +{ + var config = app.Services.GetRequiredService(); + if (config is IConfigurationRoot root) + { + var loggerFactory = app.Services.GetRequiredService(); + foreach (var configProvider in root.Providers.OfType()) + { + configProvider.Source.LoggerFactory = loggerFactory; + } + } + + return app; +} +``` + ## Acknowledgements This library is inspired by `Kralizek.Extensions.Configuration.AWSSecretsManager`. diff --git a/src/W4k.Extensions.Configuration.Aws.SecretsManager/Diagnostics/ActivityDescriptors.cs b/src/W4k.Extensions.Configuration.Aws.SecretsManager/Diagnostics/ActivityDescriptors.cs index 3553be7..f22fd04 100644 --- a/src/W4k.Extensions.Configuration.Aws.SecretsManager/Diagnostics/ActivityDescriptors.cs +++ b/src/W4k.Extensions.Configuration.Aws.SecretsManager/Diagnostics/ActivityDescriptors.cs @@ -15,12 +15,12 @@ public static class ActivityDescriptors /// /// Name of activity representing load of secrets from AWS Secrets Manager. /// - public static readonly string LoadActivityName = "Load"; + public static readonly string LoadActivityName = "W4k.SecretsManager.Load"; /// /// Name of activity representing reload of secrets from AWS Secrets Manager. /// - public static readonly string ReloadActivityName = "Reload"; + public static readonly string ReloadActivityName = "W4k.SecretsManager.Reload"; - internal static ActivitySource Source { get; } = new(ActivitySourceName, "2.0"); + internal static ActivitySource Source { get; } = new(ActivitySourceName, "2.1"); } \ No newline at end of file