'Android Studio: Logcat vs Run

What's the difference between Logcat and Run in Android-Studio?

Logcat has filter-options. Beside that I don't get which specific purpose each serve.

In how far do the messages differ, which become printed to each console?

When do I use which console?

enter image description here



Solution 1:[1]

Personally,Logcat is more useful for debugging and being aware of what is going on while the app is running. You set the type of the log and set tags to them, by this way you can easily filter logs. This gives you much more clear picture in terms of logging.it stated in this article

Logcat is a command-line tool that dumps a log of system messages, including stack traces when the device throws an error and messages that you have written from your app with the Log class.

Also, it is stated that (in the same article)

The priority is one of the following character values, ordered from lowest to highest priority:

  • V: Verbose (lowest priority)
  • D: Debug
  • I: Info
  • W: Warning
  • E: Error
  • F: Fatal
  • S: Silent (highest priority, on which nothing is ever printed)

each one of these shows the logs from their priority to highest one . Verbose, for instance, will print all the logs but if you switch to error , logcat only shows error and fatal logs.

Additionally, if you set a tag filter it will only shows the logs that is tagged with that "tag", of course while keeping the priority filter. For instance

Log.e("tag1","message_1");
Log.e("tag2","message_2");

Assume you have filter the tags with "tag1". The logcat will print "message_1". Similarly

Log.e("tag1","message_1");
Log.i("tag1","message_2");

Again, assume that you have filter tags by "tag1" and priorities with Error.Then, the logcat will show only "message_1".

For the run tool also shows logs , prints (println etc.) but in comparison with the logcat it will show a lot more stuff (logs, prints (println etc. and phone related informations). apart from your logs other logs that comes from libraries and phone itself also are shown in the run tool. So it hard to find your own logs.

Run will be useful when the phone and library related information logs needed.(for instance when the phone misses/drop frames it will be printed in run)

Logcat will be useful for your own logs.When you are trying to understand what is going on while the app runs etc..

Solution 2:[2]

I have noticed a big difference between the run and the logcat while using avd emulators. I had a deceiving crash on my app, only while I was using the emulators . every time there was a crash , the logs before the crash were disappearing from the logcat , and I couldn't understand if I see the logs related to the crash. after a week of trying to find a library that prints the logs to a file I found out that everything is printed in the run tab, so I don't need that.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Gilad Levinson