Skip to content

Saving logs on an end user’s device#

In LUNA ID for Android#

Automatic session logging with showCamera#

To get log files and save them on your device:

1․ Enable logging in LUNA ID: LunaID.showCamera(logToFile = true).

Every call of showCamera with logToFile set to true will create a log file with a session of getting the best shot on your mobile device.

2․ Get the log files by calling Context#getFilesDir(). The files are stored in the logs folder inside your app’s private folder. For details, see getFileDir.

We do not provide a solution for getting log files from your device. You need to realize it in your code by yourself. That is, you will need to add logic for getting these log files and sending them, for example, to your endpoint or to your mail.

We recommend that you do the following to get logs from your device:

1․ In your app, realize hidden camera launching with collecting of logs. For example, you can do it by long-tapping the camera button or via the hidden developer menu in the release build.

2․ When a user has a problem getting the best shot, you get the logs and forward them to our Support Team.

Saving logs in the .logcat format#

Starting from v.1.19.0, LUNA ID for Android provides the ability to save internal SDK logs into a file on the device's internal storage in the .logcat format. This feature is particularly useful for debugging issues in release builds, where direct access to real-time log output (for example, via Android Studio) is not possible.

You can use the dumpLogs() function to explicitly write collected logs to a specified file.

If no output file is specified, logs are saved by default to \<app_private_directory>/files/logs.logcat.

Usage example:

val file = File(application.filesDir, "logs.logcat")

dumpLogs(
    context = application,
    outputFile = file
)

After the logs are written, you can upload them to your preferred monitoring or analytics service. For example, using Sentry:

uploadFileToSentry(file)

In LUNA ID for iOS#

When using a logging-enabled build, you can retrieve the log file path by calling [LCLunaConfiguration logfile] and implement your own logic to collect or upload the logs. The [LCLunaConfiguration logfile] method is especially useful for diagnosing critical issues such as license activation failures. However, you cannot enable this functionality on your own — it must be included in the build by VisionLabs.