FeatureFlags.AdaptiveLogging
1.0.13
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
dotnet add package FeatureFlags.AdaptiveLogging --version 1.0.13
NuGet\Install-Package FeatureFlags.AdaptiveLogging -Version 1.0.13
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FeatureFlags.AdaptiveLogging" Version="1.0.13" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FeatureFlags.AdaptiveLogging" Version="1.0.13" />
<PackageReference Include="FeatureFlags.AdaptiveLogging" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FeatureFlags.AdaptiveLogging --version 1.0.13
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FeatureFlags.AdaptiveLogging, 1.0.13"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FeatureFlags.AdaptiveLogging@1.0.13
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FeatureFlags.AdaptiveLogging&version=1.0.13
#tool nuget:?package=FeatureFlags.AdaptiveLogging&version=1.0.13
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FeatureFlags.AdaptiveLogging
Adaptive logging driven by Azure App Configuration feature flags.
What it does
- Wires feature flags from configuration via
AddFeatureFlagsFromConfiguration(). - Registers services via
AddFeatureFlagDrivenLogging(). - Uses
AppConfig_RefreshInSecondsas the refresh interval for both Azure App Configuration feature flag refresh and the local refresh throttle. - Defaults
AppConfig_RefreshInSecondsto300seconds when it is missing or invalid. - Keeps the application running when App Configuration is missing, unavailable, over quota, or returns an unexpected error. In those cases, feature checks fall back to
false. - Uses zero Azure SDK retries and a short fail-fast timeout so
429 Too Many Requestsand no-response cases do not keep blocking the service. - When the feature flag is on,
DebugandTracelogs are allowed through and are emitted asInformationwhen needed with a[FORCED-<LEVEL>]prefix. - Adds a custom log prefix only when
customIdis provided.
Configuration
{
"AppConfig_ConnectionString": "Endpoint=...;Id=...;Secret=...",
"AppConfig_Label": "dev|ProjectX",
"AppConfig_RefreshInSeconds": 300,
"Logging_LogLevel_Default": "Information"
}
Required keys:
AppConfig_ConnectionString
Optional keys:
AppConfig_LabelAppConfig_RefreshInSecondsLogging_LogLevel_Default
If AppConfig_ConnectionString is not provided, the package skips Azure App Configuration and all feature checks return false.
Install
dotnet add package FeatureFlags.AdaptiveLogging
Startup
builder.Configuration.AddFeatureFlagsFromConfiguration();
builder.Services.AddFeatureFlagDrivenLogging();
Usage
Async:
var featureLogger = await logger.EnableDebugAsync("LogEndpointA");
featureLogger.LogInformation("Request received");
featureLogger.LogDebug("Extra details when the flag is enabled");
var enabled = await logger.IsFeatureEnabledAsync("LogEndpointA");
Sync:
var featureLogger = logger.EnableDebug("LogEndpointA", customId: "REQ-123");
featureLogger.LogInformation("Request received");
featureLogger.LogDebug("Extra details when the flag is enabled");
var enabled = logger.IsFeatureEnabledSync("LogEndpointA");
Checking the wrapped logger:
var featureLogger = await logger.EnableDebugAsync("LogEndpointA");
if (featureLogger.IsFeatureEnabled())
{
featureLogger.LogDebug("Flag is on");
}
Runtime behavior
- Missing or invalid feature flag name returns standard logging behavior and
falsefor feature checks. - If Azure App Configuration cannot be loaded during startup, startup continues and remote flags are not loaded.
- If Azure App Configuration fails during refresh or evaluation, the package does not retry, the exception is contained, and the feature is treated as disabled.
- After a failed App Configuration call, the package keeps returning
falseuntil the next allowed refresh window instead of repeatedly hammering the remote service. - If
AppConfig_RefreshInSecondsis not configured,300is used.
Public API
AddFeatureFlagsFromConfiguration(this IConfigurationBuilder builder, Action<AzureAppConfigurationOptions>? extra = null)AddFeatureFlagDrivenLogging(this IServiceCollection services)Task<ILogger> EnableDebugAsync(this ILogger logger, string featureFlag, string? customId = null)ILogger EnableDebug(this ILogger logger, string featureFlag, string? customId = null)Task<bool> IsFeatureEnabledAsync(this ILogger logger, string featureFlag)bool IsFeatureEnabledSync(this ILogger logger, string featureFlag)bool IsFeatureEnabled(this ILogger logger)
Changelog (high-level)
[1.0.13]
- Removed Azure App Configuration retries for this package and added a short fail-fast request timeout.
429 Too Many Requests, no-response cases, and unexpected App Configuration errors now fall back immediately tofalsewithout breaking the service.- After a failed refresh, the package keeps the feature disabled until the next allowed refresh interval instead of retrying on every call.
[1.0.12]
- Azure App Configuration is now loaded in fail-open mode so application startup continues even when the store is unavailable, missing, or over quota.
- Feature flag checks now safely fall back to
falseinstead of breaking linked applications when configuration cannot be refreshed or loaded. AppConfig_RefreshInSecondsnow defaults to300seconds when omitted or invalid.- README was aligned to the current underscore-based configuration used by consuming applications.
[1.0.11]
- Fixed log evaluation logic so that when the feature flag is ON, only logs lower than
Informationare forced toInformation. When OFF, logs are evaluated strictly against the default active minimum level.
[1.0.10]
- Corrected logic in
FeatureLoggerExtensions.csto accurately comparelogLevelwithdefaultLevelwhen evaluating effective log levels.
[1.0.9]
- Restored backward compatibility. Configuration now correctly falls back from flat
AppConfig_keys to hierarchicalAppConfig:keys. - Supported flat keys:
AppConfig_ConnectionString,AppConfig_Label,AppConfig_RefreshInSeconds.
[1.0.8]
- Replaced
AppConfig:keys withAppConfig_keys to fix injection issues on environments stripping colons.
[1.0.7]
- Added synchronous API:
EnableDebug,IsFeatureEnabledSync, and a privateRefreshConfigurationhelper. - The sync methods use
Task.Runinternally to avoidSynchronizationContextdeadlocks on .NET Framework 4.x. - All existing async methods remain unchanged and are still the recommended choice on modern .NET.
[1.0.6]
- Added
SetRefreshIntervalfor Feature Flags SDK refresh window fromAppConfig_RefreshInSeconds.
[1.0.5]
- Fixed an initialization order bug where
InvalidOperationExceptionwas thrown prematurely if the Azure App Config builder was called beforeappsettings.jsonwas fully loaded into the host configuration. - Added explicit null handling in
EnableDebugAsync.
[< 1.0.4]
- Automatic correlation id when not provided.
- Unified refresh interval for SDK and local throttle.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.AzureAppConfiguration (>= 8.5.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Microsoft.FeatureManagement (>= 4.4.0)
-
net10.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Configuration.AzureAppConfiguration (>= 8.5.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.FeatureManagement (>= 4.4.0)
-
net6.0
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.AzureAppConfiguration (>= 8.5.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Microsoft.FeatureManagement (>= 4.4.0)
-
net8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.AzureAppConfiguration (>= 8.5.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Microsoft.FeatureManagement (>= 4.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.