FeatureFlags.AdaptiveLogging 1.0.13

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" />
                    
Directory.Packages.props
<PackageReference Include="FeatureFlags.AdaptiveLogging" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=FeatureFlags.AdaptiveLogging&version=1.0.13
                    
Install as a Cake Tool

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_RefreshInSeconds as the refresh interval for both Azure App Configuration feature flag refresh and the local refresh throttle.
  • Defaults AppConfig_RefreshInSeconds to 300 seconds 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 Requests and no-response cases do not keep blocking the service.
  • When the feature flag is on, Debug and Trace logs are allowed through and are emitted as Information when needed with a [FORCED-<LEVEL>] prefix.
  • Adds a custom log prefix only when customId is 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_Label
  • AppConfig_RefreshInSeconds
  • Logging_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 false for 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 false until the next allowed refresh window instead of repeatedly hammering the remote service.
  • If AppConfig_RefreshInSeconds is not configured, 300 is 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 to false without 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 false instead of breaking linked applications when configuration cannot be refreshed or loaded.
  • AppConfig_RefreshInSeconds now defaults to 300 seconds 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 Information are forced to Information. When OFF, logs are evaluated strictly against the default active minimum level.

[1.0.10]

  • Corrected logic in FeatureLoggerExtensions.cs to accurately compare logLevel with defaultLevel when evaluating effective log levels.

[1.0.9]

  • Restored backward compatibility. Configuration now correctly falls back from flat AppConfig_ keys to hierarchical AppConfig: keys.
  • Supported flat keys: AppConfig_ConnectionString, AppConfig_Label, AppConfig_RefreshInSeconds.

[1.0.8]

  • Replaced AppConfig: keys with AppConfig_ keys to fix injection issues on environments stripping colons.

[1.0.7]

  • Added synchronous API: EnableDebug, IsFeatureEnabledSync, and a private RefreshConfiguration helper.
  • The sync methods use Task.Run internally to avoid SynchronizationContext deadlocks on .NET Framework 4.x.
  • All existing async methods remain unchanged and are still the recommended choice on modern .NET.

[1.0.6]

  • Added SetRefreshInterval for Feature Flags SDK refresh window from AppConfig_RefreshInSeconds.

[1.0.5]

  • Fixed an initialization order bug where InvalidOperationException was thrown prematurely if the Azure App Config builder was called before appsettings.json was 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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.