Logging

Overview

The VPN SDK provides a built-in logging mechanism that can be enabled for debugging purposes. When enabled, the SDK generates detailed log files that can be helpful in troubleshooting issues and monitoring the VPN connection.

Enabling Debug Logging

To enable debug logging in the VPN SDK, you need to pass the isDebugLoggingEnabled flag as true in the ModuleConfiguration of the VPNSDKConfiguration. Here's an example:

var hydraConfiguration = HydraConfiguration(
    // ...
    modulesConfiguration: ModulesConfiguration(isDebugLoggingEnabled: true),
    // ...
)

By setting isDebugLoggingEnabled to true, the VPN SDK will start generating detailed log files for debugging purposes.

Adding Log Encoding Credentials

Starting from version 6.8.0 of Unified VPN SDK for Apple it is possible to add CryptographicCredentials for Hydra and WireGuard along with Combined configurations to be used in Log Encoding and later Decoding processes.

To add custom CryptographicCredentials you need to initialise such instance with key and iv values and pass it to the logCryptographicCredentials: CryptographicCredentials? property:

let logCryptographicCredentials = CryptographicCredentials(key: "YOUR_CRYPTOGRAPHIC_KEY",
                                                           iv: "YOUR_CRYPTOGRAPHIC_IV")
let validatedLogCryptographicCredentials = logCryptographicCredentials.isValid ?
                                           logCryptographicCredentials : nil
var hydraConfiguration = HydraConfiguration(
    // ...
    logCryptographicCredentials: validatedLogCryptographicCredentials,
    // ...
)

logCryptographicCredentials property in any configuration is optional and can be omitted having default value of nil. In this case default credentials will be used for log encoding and can be decoded only by Apple VPN SDK Team per request from the Partner’s development team.

Accessing Log Files

Once debug logging is enabled, you can access the generated log files using the VPNLogSharingHelper class. This class provides static methods for retrieving the log file URLs or presenting a sharing activity to share the log files.

Viewing Logs in Real-time

Viewing Logs in Real-time In addition to accessing log files, you can view the same logs in real-time:

  • For the application process, the logs can be viewed directly in the Xcode console.

  • For the VPN extension process, the logs can be viewed using the macOS app "Console". To filter the logs, use the extension process name.

Log File Encoding

Please note that the generated log files are encoded. To decode the log files, clients need to use a script provided by us. We will provide the necessary decoding script to clients upon request.

Decoding Encoded VPN SDK Logs

For more information, please see Decoding encoded VPN SDK logs.

Last updated