diff --git a/website/docs/sdk-reference/dotnet.mdx b/website/docs/sdk-reference/dotnet.mdx index 286702b3..d15e87ac 100644 --- a/website/docs/sdk-reference/dotnet.mdx +++ b/website/docs/sdk-reference/dotnet.mdx @@ -102,13 +102,15 @@ These are the available options on the `ConfigCatClientOptions` class: | Properties | Description | Default | | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | | `PollingMode` | Optional, sets the polling mode for the client. [More about polling modes](#polling-modes). | `PollingModes.AutoPoll()` | +| `ConfigFetcher` | Optional, [`IConfigCatConfigFetcher`](https://github.com/configcat/.net-sdk/blob/master/src/ConfigCatClient/ConfigService/IConfigCatConfigFetcher.cs) instance for downloading a config. | [`HttpClientConfigFetcher`](https://github.com/configcat/.net-sdk/blob/master/src/ConfigCatClient/ConfigService/HttpClientConfigFetcher.cs) | | `ConfigCache` | Optional, [`IConfigCatCache`](https://github.com/configcat/.net-sdk/blob/master/src/ConfigCatClient/Cache/IConfigCatCache.cs) instance for caching the downloaded config. | [`InMemoryConfigCache`](https://github.com/configcat/.net-sdk/blob/master/src/ConfigCatClient/Cache/InMemoryConfigCache.cs) | | `Logger` | Optional, [`IConfigCatLogger`](https://github.com/configcat/.net-sdk/blob/master/src/ConfigCatClient/Logging/IConfigCatLogger.cs) instance for tracing. | [`ConsoleLogger`](https://github.com/configcat/.net-sdk/blob/master/src/ConfigCatClient/Logging/ConsoleLogger.cs) (with WARNING level) | +| `LogFilter` | Optional, sets a custom log filter. [More about log filtering](#log-filtering). | `null` (none) | | `BaseUrl` | Optional, sets the CDN base url (forward proxy, dedicated subscription) from where the SDK will download the config JSON. | | -| `HttpClientHandler` | Optional, `HttpClientHandler` to provide network credentials and proxy settings. [More about the proxy settings](#using-configcat-behind-a-proxy). | built-in `HttpClientHandler` | +| `HttpClientHandler` | Optional, `HttpClientHandler` to provide network credentials and proxy settings. [More about the proxy settings](#using-configcat-behind-a-proxy). | built-in `HttpClientHandler` | | `HttpTimeout` | Optional, sets the underlying HTTP client's timeout. [More about the HTTP timeout](#http-timeout). | `TimeSpan.FromSeconds(30)` | | `FlagOverrides` | Optional, sets the local feature flag & setting overrides. [More about feature flag overrides](#flag-overrides). | | -| `DataGovernance` | Optional, defaults to `Global`. Describes the location of your feature flag and setting data within the ConfigCat CDN. This parameter needs to be in sync with your Data Governance preferences. [More about Data Governance](../advanced/data-governance.mdx). Available options: `Global`, `EuOnly` | `Global` | +| `DataGovernance` | Optional, defaults to `Global`. Describes the location of your feature flag and setting data within the ConfigCat CDN. This parameter needs to be in sync with your Data Governance preferences. [More about Data Governance](../advanced/data-governance.mdx). Available options: `Global`, `EuOnly` | `Global` | | `DefaultUser` | Optional, sets the default user. [More about default user](#default-user). | `null` (none) | | `Offline` | Optional, determines whether the client should be initialized to offline mode. [More about offline mode](#online--offline-mode). | `false` | @@ -703,10 +705,30 @@ ConfigCat.INFO [5000] Evaluating 'isPOCFeatureEnabled' for User '{"Identifier": Returning 'True'. ``` +### Custom logger implementation + +By default, the SDK logs to [the console's standard output](https://learn.microsoft.com/en-us/dotnet/api/system.console.out) but it also allows you to inject any custom logger implementation via the `ConfigCatClientOptions.Logger` property. + Sample code on how to create a basic file logger implementation for ConfigCat client: See Sample Code Another sample which shows how to implement an adapter to [the built-in logging framework](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging) of .NET Core/.NET 5+: See Sample Code +### Log Filtering + +You can define a custom log filter by providing a callback function via the `ConfigCatClientOptions.LogFilter` property. The callback will be called by the _ConfigCat SDK_ each time a log event occurs (and the event passes the minimum log level specified by the `IConfigCatLogger.LogLevel` property). That is, the callback allows you to filter log events by `level`, `eventId`, `message` or `exception`. The formatted message string can be obtained via `message.InvariantFormattedMessage`. +If the callback function returns `true`, the event will be logged, otherwise it will be skipped. + +```cs +// Filter out events with id 1001 from the log. +LogFilterCallback logFilter = (LogLevel level, LogEventId eventId, ref FormattableLogMessage message, Exception? exception) => eventId != 1001; + +var client = ConfigCatClient.Get("#YOUR-SDK-KEY#", options => options.LogFilter = logFilter); +``` + +:::caution +Please make sure that your log filter logic doesn't perform heavy computation and doesn't block the executing thread. A complex or incorrectly implemented log filter can degrade the performance of the SDK. +::: + ## `GetAllKeysAsync()` You can get all the setting keys from your configuration by calling the `GetAllKeysAsync()` method of the `ConfigCatClient`. @@ -870,6 +892,27 @@ IConfigCatClient client = ConfigCatClient.Get("#YOUR-SDK-KEY#", options => The default timeout is 30 seconds. +## Platform compatibility + +The _ConfigCat SDK_ supports all the widespread .NET JIT runtimes, everything that implements [.NET Standard 2.0](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0)+ and supports TLS 1.2 should work. +Starting with v9.3.0, it can also be used in applications that employ [trimmed self-contained](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained) or various [ahead-of-time (AOT) compilation](https://en.wikipedia.org/wiki/Ahead-of-time_compilation) deployment models. + +Based on our tests, the SDK is compatible with the following runtimes/deployment models: +* .NET Framework 4.5+ (including Ngen) +* .NET Core 3.1, .NET 5+ (including Crossgen2/ReadyToRun and Native AOT) +* Mono 5.10+ +* .NET for Android (formerly known as Xamarin.Android) +* .NET for iOS (formerly known as Xamarin.iOS) +* Unity 2021.3+ (Mono JIT) +* Unity 2021.3+ (IL2CPP)* +* Universal Windows Platform 10.0.16299.0+ (.NET Native)** +* WebAssembly (Mono AOT/Emscripten, also known as wasm-tools) + +*Unity WebGL also works but needs a bit of extra effort: you will need to enable WebGL compatibility by calling the `ConfigCatClient.PlatformCompatibilityOptions.EnableUnityWebGLCompatibility` method. For more details, see [Sample Scripts](https://github.com/configcat/.net-sdk/tree/master/samples/UnityWebGL).
+**To make the SDK work in Release builds on UWP, you will need to add `` to your application's [.rd.xml](https://learn.microsoft.com/en-us/windows/uwp/dotnet-native/runtime-directives-rd-xml-configuration-file-reference) file. See also [this discussion](https://github.com/dotnet/runtime/issues/29912#issuecomment-638471351). + +We strive to provide an extensive support for the various .NET runtimes and versions. If you still encounter an issue with the SDK on some platform, please open a [GitHub issue](https://github.com/configcat/.net-sdk/issues/new/choose) or contact support. + ## Troubleshooting When the _ConfigCat SDK_ does not work as expected in your application, please check for the following potential problems: @@ -904,7 +947,9 @@ When the _ConfigCat SDK_ does not work as expected in your application, please c Check out our Sample Applications how they use the _ConfigCat SDK_: - Sample Console App -- Sample Web App +- Sample Multi-page Web App (ASP.NET Core MVC) +- Sample Single-page Web App (ASP.NET Core Blazor WebAssembly) +- Sample Mobile/Windows Store App (.NET MAUI) ## Guides diff --git a/website/docs/sdk-reference/java.mdx b/website/docs/sdk-reference/java.mdx index 00505383..9fbb3edb 100644 --- a/website/docs/sdk-reference/java.mdx +++ b/website/docs/sdk-reference/java.mdx @@ -119,11 +119,11 @@ These are the available options on the `Options` class: | `cache(ConfigCache)` | Optional, sets a custom cache implementation for the client. [More about cache](#custom-cache). | | `pollingMode(PollingMode)` | Optional, sets the polling mode for the client. [More about polling modes](#polling-modes). | | `logLevel(LogLevel)` | Optional, defaults to `WARNING`. Sets the internal log level. [More about logging](#logging). | +| `logFilter(LogFilterFunction)` | Optional, sets a custom log filter. [More about log filtering](#log-filtering). | | `flagOverrides(OverrideDataSourceBuilder, OverrideBehaviour)` | Optional, sets the local feature flag & setting overrides. [More about feature flag overrides](#flag-overrides). | | `defaultUser(User)` | Optional, sets default user. [More about default user](#default-user). | | `offline(boolean)` | Optional, defaults to `false`. Indicates whether the SDK should be initialized in offline mode. [More about offline mode](#online--offline-mode). | | `hooks()` | Optional, used to subscribe events that the SDK sends in specific scenarios. [More about hooks](#hooks). | -| `logFilter(LogFilterFunction)` | Optional, sets a custom log filter. [More about log filtering](#log-filtering). | :::caution We strongly recommend you to use the `ConfigCatClient` as a Singleton object in your application. @@ -874,16 +874,19 @@ Examples fo options.logFilter(filterLogFunction)); +ConfigCatClient client = ConfigCatClient.get("#YOUR-SDK-KEY#", options -> options.logFilter(filterLogFunction)); ``` -> Please make sure that your log filter logic doesn't perform heavy computation and doesn't block the executing thread. A complex or incorrectly implemented log filter can degrade the performance of the SDK. + +:::caution +Please make sure that your log filter logic doesn't perform heavy computation and doesn't block the executing thread. A complex or incorrectly implemented log filter can degrade the performance of the SDK. +::: ## Sample Apps