Rate this page:

Collecting logs: iOS

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

Contents:

Copy URL

Collect logs from the Xcode console

Copy URL

iOS SDK prints the logs to the Xcode console in debug mode without any additional setup.

  1. Open Console from the menu bar by selecting ViewDebug AreaActivate Console.
Xcode console
  1. Add a #VI tag in the console filter.
VI tag
  1. Once the collection is complete, select everything with ⌘ + A, paste it into any text editor, and save the file. The recommended file extensions are “.log” and “.txt”.

Write logs to a file

Copy URL

There are two ways of writing logs to a file: via VILogDelegate or CocoaLumberjackSwift.

Collect logs to a file via VILogDelegate

Voximplant iOS SDK provides the VILogDelegate protocol to collect the SDK log messages and save them in any convenient place, for example into a file.

VILogDelegate protocol allows the applications to implement a log handler method that provides the following information:

  • The log message level represented by VILogSeverity enum

  • Log message in String format

It is recommended to add a timestamp to each log message before writing it to a file.

Sample FileLogger

Sample FileLogger

Collect logs to a file via CocoaLumberjack

You can also use ready-made logging solutions like CocoaLumberjack. CocoaLumberjack provides additional capabilities for log setup such as the maximum log file size, and cleanup interval.

Preconditions

CocoaLumberjackSwift should be installed first according to its official documentation

Sample FileLogger with CocoaLumberjack

Sample FileLogger with CocoaLumberjack

Get a log file from a device

Copy URL

If the application is built in the debug mode, it is possible to get a log file from the device using Xcode.

  1. Open Devices and Simulators from the menu bar by selecting WindowDevices and Simulators
Devices and Simulators
  1. Select the device and the application, then download the container.
Download container
  1. Right-click on the downloaded file with .xcappdata extension and click Show package contents. The log file is located in the AppDataDocuments path.
Contents

Redirect iOS SDK logs to the Mac Console

Copy URL

It is also possible to redirect iOS SDK logs to the Mac Console.

This approach allows developers to collect the logs as well as see them in real-time.

This approach should only be used for debugging purposes.

Redirecting the logs in the production builds can cause security incidents as the logs may contain sensitive information such as Voximplant account name, IP address, text messages received from VoxEngine scenario.

Sample

Sample