From 2c62c90d767ce96bbe43c961f1136bf9de397f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B3th=20D=C3=A1niel?= Date: Tue, 2 Jul 2024 16:22:20 +0200 Subject: [PATCH] Add logFilter hook and Log Filter section to the SDK doc. --- website/docs/sdk-reference/java.mdx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/website/docs/sdk-reference/java.mdx b/website/docs/sdk-reference/java.mdx index dda9c265..a11f62b9 100644 --- a/website/docs/sdk-reference/java.mdx +++ b/website/docs/sdk-reference/java.mdx @@ -123,6 +123,7 @@ These are the available options on the `Options` class: | `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, used to set custom log filter implementation. [More about log filter](#log-filter). | :::caution We strongly recommend you to use the `ConfigCatClient` as a Singleton object in your application. @@ -871,6 +872,19 @@ You have the flexibility to use any slf4j implementation for logging with Config Examples fo slf4j-simple and logback are available under the [Sample Apps](#sample-apps) section. +### Log Filter + +You can set a custom log filter option by implementing the `LogFilterFunction` interface. The `apply` method provide the options to filter by `logLevel`, `eventId`, `message` or `exception`. +If the `apply` method return with `true`, the event will be logged. + +```java + //Filter out the logs with the eventId 1001. + LogFilterFunction filterLogFunction = ( LogLevel logLevel, int eventId, String message, Throwable exception) -> eventId != 1001; + + ConfigCatClient client = ConfigCatClient.get("#YOUR-SDK-KEY#", options -> options.logFilter(filterLogFunction)); +``` +> A complex or a badly implemented log filter can affect the SDK efficiency. + ## Sample Apps Check out our Sample Applications how they use the ConfigCat SDK