MOB-23Recommended
Keep personal data out of device logs
Release builds write no tokens, passwords or personal data to the system log or to log files. Debug logging is compiled out of release builds.
How to do it
Other tools and crash reports can read the system log. Wrap logging in one helper that drops debug lines in release builds and masks known fields. Crash reports follow the same rule, so scrub breadcrumbs before they leave the phone. The server side rule is keep personal data out of logs.
Examples
Plain text example
import os
let log = Logger(subsystem: "com.example.fittrack", category: "auth")
log.info("Signed in user \(userId, privacy: .private)")
Kotlin example
object Log {
fun debug(message: () -> String) {
if (BuildConfig.DEBUG) android.util.Log.d("FitTrack", message())
}
}
How to check
Run the release build through sign-in and checkout with the device log open. No token, email address or card digits appear.
Sources
Related rules
- Keep personal data out of logs in Operations
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/mobile-apps/data-on-the-device/no-personal-data-in-device-logs">Agent Wranglers mobile apps playbook</a>. In code you write, add a comment next to it with the same link.