Remote Logger

Remote logger helps you to get the applications logs without asking the users. 

Before you begin, ensure that Apptics is integrated into your project by following the Integration Guide.

Add remote logger

  • Declare the Remote Logger dependency using Apptics BoM.
Copieddependencies {
  // ...

  // Apptics BoM, latest version is mentioned in the integration guide.
  implementation platform('com.zoho.apptics:apptics-bom:[latest-version]')
  
  // Since BoM version is specified, no need to explicitly specify the dependency version.
  implementation 'com.zoho.apptics:apptics-logger'

}
  • Alternatively, if you choose not to use Apptics BoM, you can directly declare the remote logger dependency with its version.
Copieddependencies {
   // Have to explicitly mention the version, if you are not using BoM.
   // latest version is mentioned in the integration guide.
   implementation 'com.zoho.apptics:apptics-logger:[latest-version]'
}

Note: We highly recommend using Apptics BoM to avoid unnecessary compatibility issues.

  • Initialise AppticsLogger in Application onCreate() method.​
CopiedApptics.init(this)

Enable/Disable remote logger

Remote logging is disabled by default. You can use the below methods to enable/disable or get the current state of Remote Logger.

Note: Remote Logger will be automatically turned off if Usage Tracking is disabled. You can refer to the Tracking Settings.

We have also included the logger enable/disable the option in our Analytics settings activity, refer to the Consent.

  • To enable the remote logger, follow the below.
CopiedAppticsLogger.enable()
  • To disable the remote logger, follow the below.
CopiedAppticsLogger.disable()
  • To get the current status of the remote logger, follow the below.
CopiedAppticsLogger.isEnabled()

Send logs to Apptics

  • Use the AppticsLogger similar to the Android Logger class to send logs to Apptics.
CopiedAppticsLogger.d("TAG", "log")
AppticsLogger.e("TAG", "log")
AppticsLogger.w("TAG", "log")
AppticsLogger.i("TAG", "log")
AppticsLogger.v("TAG", "log")
  • AppticsLogger will print the logs to logcat only if showLogs is enabled in the build.gradle.
Copiedapptics {
   showLogs = ["default": true]
}

Support for timber

AppticsLogger provides support for the Timber logging framework as well.

  • Plant the AppticsLogTree in Timber.
CopiedTimber.plant(AppticsLogTree())

How does Apptics logger work?

AppticsLogger writes the logs added by the developer in a file stored in the app's cache directory. Stored log files are uploaded to the server upon the next app cold start or periodically using job scheduler APIs.

Max offline limit of log files is set to 1MB and each log file is limited to 200kb. If the log storage exceeds the allocation, the oldest log file will be deleted to store the recent logs.