Collecting logs: iOS
This article will help you to collect logs from iOS SDK and WebRTC.
Contents:
Collect logs from the Xcode console
iOS SDK prints the logs to the Xcode console in debug mode without any additional setup.
- Open Console from the menu bar by selecting View → Debug Area → Activate Console.
- Add a
#VI
tag in the console filter.
- 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
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.
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.
CocoaLumberjackSwift should be installed first according to its official documentation
Get a log file from a device
If the application is built in the debug mode, it is possible to get a log file from the device using Xcode.
- Open Devices and Simulators from the menu bar by selecting Window → Devices and Simulators
- Select the device and the application, then download the container.
- Right-click on the downloaded file with .xcappdata extension and click Show package contents. The log file is located in the AppData → Documents path.
Redirect iOS SDK logs to the Mac Console
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.
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.