configcat / android-sdk

ConfigCat SDK for Android. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
https://configcat.com/docs/sdk-reference/android
MIT License
13 stars 3 forks source link

Logging is not working #48

Closed SumeraMartin closed 8 months ago

SumeraMartin commented 8 months ago

Describe the bug

I tried to get some log informations from ConfigCat but no informations are logged to the logcat.

To reproduce

I'm initializing the client with the following setup:

ConfigCatClient.get("321312", {
    options.pollingMode(PollingModes.autoPoll(60.minutes.inWholeSeconds.toInt()))
    options.logLevel(LogLevel.INFO)
})

then I see no log or any kind of messages from ConfigCat in the logcat.

I see only the following error which may be related to this problem since as I found information on your website that you are using slf4j logger:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Expected behavior

I expect to see some logs in the logcat.

Screenshots

No screenshots needed

SDK version

10.0.0

SDK configuration

    ...
    override fun getValueForFeatureWithParams(key: String, params: FeatureFlagsParams): Boolean {
        return configCatClient.getValue(....)
    }

    private fun createConfigCatClient(): ConfigCatClient {
        val options: (ConfigCatClient.Options) -> Unit = { options ->
            options.pollingMode(PollingModes.autoPoll(60.minutes.inWholeSeconds.toInt()))
            options.logLevel(getLogLevelBaseOnBuildFlavor())
        }

        return when (globalBuildConfig.buildFlavor) {
            BuildFlavor.DEV -> ConfigCatClient.get(Constants.ConfigCatSdkKey.DEV, options)
            BuildFlavor.STG -> ConfigCatClient.get(Constants.ConfigCatSdkKey.STG, options)
            BuildFlavor.PRD -> ConfigCatClient.get(Constants.ConfigCatSdkKey.PRD, options)
        }
    }

    private fun getLogLevelBaseOnBuildFlavor(): LogLevel {
        return when (globalBuildConfig.buildFlavor) {
            BuildFlavor.DEV -> LogLevel.ERROR
            BuildFlavor.STG -> LogLevel.WARNING // Default value
            BuildFlavor.PRD -> LogLevel.WARNING // Default value
        }
    }
    ...

Logs

Already added everything which seems to be related to ConfigCat

Language/Framework version

Java

Platform

Android

novalisdenahi commented 8 months ago

Hi @SumeraMartin,

Thanks for the feedback! I'll check the problem and get back to you as soon as possible with an answer.

novalisdenahi commented 8 months ago

Hi @SumeraMartin,

May I ask your slf4j-api dependency version?

While testing our sample app with the org.slf4j:slf4j-android:1.+ dependency. I got the same error with a newer version, 2.0.7, of the slf4j-api.

The logging worked perfectly with the following dependencies:

implementation 'org.slf4j:slf4j-api:1.7.36'
implementation 'org.slf4j:slf4j-android:1.+'

Also, it is not required to use org.slf4j:slf4j-android. You can check our sample code, where logback-android is used for logging.

Let me know if you still experience problems.

novalisdenahi commented 8 months ago

Hi @SumeraMartin,

I hope you managed to solve the logging problem. I will close this issue now, but if you are still experiencing problems, let us know.

Best Regards, Daniel