Customize the Android SDK logger
Customize log information from the Optimizely Feature Experimentation Android SDK for debugging experiments.
The logger captures details about your experiments, making it easier for you to debug them. You can customize where the log information is stored and choose the types of data you want to track.
For the Android SDK, you can use Optimizely's Android SLF4J logger. You can control logging verbosity through the android-logger.properties
file and place it in src/main/resources
. You can also include a copy in src/release/resources
with different settings for the build you release to the Play Store. Read about advanced configuration options.
To improve your experience setting up the SDK and configuring your production environment, pass in a logger for your Optimizely client. See the following code sample.
Warning
Due to a the Log4j library vulnerability, you should upgrade to version 2.15.0 or higher if you are using it with the SDK.
# android-logger.properties example (JSON)
# Java Core SDK
logger.com.optimizely.ab.Optimizely=DEBUG:Optly.core
logger.com.optimizely.ab.annotations=DEBUG:Optly.annotations
logger.com.optimizely.ab.bucketing=DEBUG:Optly.bucketing
logger.com.optimizely.ab.config=DEBUG:Optly.config
logger.com.optimizely.ab.error=DEBUG:Optly.error
logger.com.optimizely.ab.event=DEBUG:Optly.event
logger.com.optimizely.ab.internal=DEBUG:Optly.internal
# Android SDK
logger.com.optimizely.ab.android.sdk=DEBUG:Optly.androidSdk
logger.com.optimizely.ab.android.event_handler=DEBUG:Optly.eventHandler
logger.com.optimizely.ab.android.shared=DEBUG:Optly.shared
logger.com.optimizely.ab.android.user_profile=DEBUG:Optly.userProfile
# Disable most SDK logs by commenting all other lines and uncommenting below
# logger.com.optimizely.ab=ASSERT:Optly
Log levels
The following list shows the log levels for the Android SDK.
- ERROR – Logs events that prevent feature flags from working properly, such as an invalid data file during initialization or incorrect feature keys. These issues require user intervention to fix.
- WARN – Logs events that do not prevent feature flags from working properly but may cause unexpected results, such as future API deprecation, improper logger or error handler settings, and nil values from getters.
- INFO – Logs key events to illustrate the lifecycle of an API call, such as when a decision or tracking starts and succeeds.
- DEBUG – Logs extra information related to errors that aid Optimizely in debugging, like when a feature flag is not running or a user is not included in a rollout.
Updated 19 days ago