0

Sometimes when a phone connects to Android Studio, it will print logs between the time it was last connected to Android Studio and the present. This is cool, but I can not replicate it. Some times it happens, sometimes it does not.

I have a guess that this is a feature of USB and wireless debugging, and that logs are put in a temporary file so they can be sent to logcat when reconnected. If so, how do I keep the USB debugging from turning off when testing my device in the field during the day, so I can get the logs that were printed during the day? If not, what is happening?

John Glen
  • 771
  • 7
  • 24

1 Answers1

1

The logs are nothing to do with Android Studio (or logcat in general) - it's just system logging happening on the device, and that happens whether it's connected to a log-reader or not.

At a guess, what's happening is your app's process is being closed, so the next time it runs it gets a different PID (process ID). When you connect it to the computer, your dropdown shows the currently running app process, and filters by its PID, so you don't see the old stuff.

You've probably seen this while debugging - if you re-run your app, the log "clears" and gives you a fresh one for the new run of the app. The old log messages are still there (as well as a hell of a lot of other logs for all the stuff going on on the device - it is noisy), it's just that you can't see them.

The simple thing to try is going to the filter dropdown on the right of the logcat window, and choose No filtering. Then in the filter query thing next to it (with the ) type the name of your app, maybe its package. It's not perfect but it should show you all of the logs it has from your app, along with a bunch of system stuff that's also referring to it. You could get clever with PIDs or setting up a custom filter in the dropdown to get better results.

You might also be interested in the guide (with some filtering tips) and the commandline version if that's more useful to you

cactustictacs
  • 17,935
  • 2
  • 14
  • 25