2

Android apps write their logs to a file (usually referred to as "logcat") which is very useful not only for developers but also for users who want to investigate problems. You can easily see that hundreds of lines get written to logcat every time you open Facebook, Gmail, Whatsapp, or pretty much any other app.

In all recent Android versions, a logcat line is only visible to the app that wrote it, and to the human user (please correct me if anything is not exact).

As a developer, what should I never output to logcat?

  • Dialog that the user opens
  • Language choice of the user
  • Accessed URL
  • Software versions
  • User settings
  • WiFi name
  • User nickname
  • Current geolocation
  • Credit card number
  • Password
  • etc

Where to put the limit? What information, if included, would be considered a vulnerability?
Actually, I often see WiFi names in my logcat.

Context: Small open source non-critical app with only a few thousands users, many of whom send bug reports (including logcat) or even help with debugging, I rely on them and because it is a hobby and I don't have much time for testing.

1

As a developer, what should I never output to logcat?

Your release build should output nothing to LogCat.

After all, writing information to LogCat adds zero value to the user. While the CPU and battery cost is minimal, minimal is still more than zero, so the cost does not justify the (non-)value. You cannot access the user's LogCat data, except where you are the user (or the user happens to be an Android developer).

As a side benefit, you will not leak private information or security data to LogCat, if you do not log anything to LogCat in your release build.

  • Interesting! How do you explain that most apps (Facebook, Gmail, Whatsapp, Shazam, etc) write generously to logcat? As the last paragraph of my question mentions, logcat has a lot of value for my app even in the release version. – Nicolas Raoul Jul 29 '18 at 4:11
  • 1
    If logcat output is important allow users to enable a logging mode in settings. It should not be enabled by default for the reasons above – Sirens Jul 29 '18 at 4:19
  • @NicolasRaoul: "logcat has a lot of value for my app even in the release version" -- no, logging has a lot of value. LogCat is a convenient but insecure means of logging. If you wish to log, make it opt-in as Sirens points out, and log to a file on internal storage. Add a "submit logs" button somewhere to send the current log contents to your email, server, etc. – CommonsWare Jul 29 '18 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.