Android: Collecting logs

Collect Android SDK logs for troubleshooting in Voximplant.
View as Markdown

This article will help you to collect logs from Android SDK and WebRTC.

Collect Logcat logs (from Android Studio)

Logcat is a command-line tool that dumps a log of system messages when the device throws an error and sends messages that you have written from your app with the Log class.

  1. Open Logcat tab in Android Studio or select ViewTool WindowsLogcat from the menu bar.
  2. Filter device logs by the VOXSDK tag.
  3. We recommend enabling timestamp in Datetime format and thread id in the Logcat Formatting Options.

Logcat

Logcat Formatting options

  1. Reproduce the problem
  2. Once the problem is reproduced, select all logs in the logcat with Ctrl + A (Windows, Linux, Chrome OS) or ⌘ + A (Mac), paste it into any text editor, and save the file. The recommended file extensions are “.log” and “.txt”

Learn more about Logcat in the Android Developers user guide.

Collect logs to file (from Application)

Voximplant Android SDK provides the ILogListener interface that allows developers to collect the SDK log messages and save them in any convenient place, for example into a file.

ILogListener interface allows the applications to implement a log handler method that provides the following information:

  1. log message level represented by LogLevel enum
  2. log message in String format

A file logger can be configured at an application startup.

Sample FileLogger
1// (1) should implement ILogListener interface
2class FileLogger(context: Context) : ILogListener {
3 private lateinit var fileHandler: FileHandler
4
5 init {
6 // The log file is saved to the `data/data/app_name/` directory.
7 fileHandler = FileHandler(context.filesDir.path + "/VOXSDK.log").apply {
8 formatter = SimpleFormatter()
9 }
10 // (2) Invoke Voximplant.setLogListener() to handle Voximplant SDK log messages.
11 Voximplant.setLogListener(this)
12 }
13
14 // (3) Write a log message in ILogListener.onLogMessage to a file.
15 override fun onLogMessage(level: LogLevel, log: String) {
16 val logLevel = when (level) {
17 LogLevel.ERROR -> Level.SEVERE
18 LogLevel.WARNING -> Level.WARNING
19 LogLevel.INFO -> Level.INFO
20 LogLevel.DEBUG -> Level.CONFIG
21 LogLevel.VERBOSE -> Level.FINEST
22 }
23 fileHandler.publish(LogRecord(logLevel, log))
24 }
25}

Extended logs

Voximplant Android SDK allows developers to enable extended logs that include WebRTC logs of level info, warnings, and errors.

It is important to consider that extended logs will lead to a significant increase in the volume of logs, and may also affect application performance. It is recommended that extended logs are enabled only for diagnosing problems with audio and video transmission and at the request of technical support specialists.

To enable extended logs, use ClientConfig.enableDebugLogging on the SDK initialization:

enableDebugLogging
1val clientConfig = ClientConfig().apply {
2 enableDebugLogging = true
3}
4Voximplant.getClientInstance(Executors.newSingleThreadExecutor(), context, clientConfig)