I am using custom ReleaseTree
for my application using Timber to filter the logs. But when building the release apk application logs are not showing in logcat. When using Timber.DebugTree()
in release build logs are showing properly.
Here is my ReleaseTree class:
class ReleaseTree : Timber.Tree() {
override fun log(priority: Int, tag: String?, message: String, throwable: Throwable?) {
// Don't log VERBOSE, DEBUG and INFO
if (priority == Log.VERBOSE) {
return
}
if (priority == Log.ERROR){
val t = throwable ?: Exception(message)
// Crashlytics
Crashlytics.setInt(CRASHLYTICS_KEY_PRIORITY, priority)
Crashlytics.setString(CRASHLYTICS_KEY_TAG, tag)
Crashlytics.setString(CRASHLYTICS_KEY_MESSAGE, message)
Crashlytics.logException(t)
}
}
companion object {
private val CRASHLYTICS_KEY_PRIORITY = "Priority"
private val CRASHLYTICS_KEY_TAG = "Tag"
private val CRASHLYTICS_KEY_MESSAGE = "Message"
}
}
How I am initializing the ReleaseTree from Application class:
Fabric.with(this, new Crashlytics());
Timber.plant(new ReleaseTree());