Android Studio Pro Tip: go to source from logcat output
.([filename].java:[line]) in your log statements to make them clickable in Android Studio and Intellij IDEA.
Have you ever looked at the log output of your app and wondered where exactly the log lines are generated? The process for me used to be:
cmd+oto open the “Navigate to class..” prompt and type in the tag from the log line (I’m almost always using class names as log tags. I guess most of us do, right?) to open the class where the log line is printed.
cmd+f to open the find prompt and type in the relevant log line.
3. Hope that this log line is printed in only one place inside this class 🙏 …
But not anymore — my logcat output now looks like this:
- Precious milliseconds and keystrokes saved! Links are clickable and take you directly to the place where the log is printed. 🎉
- Log tags are freed up and can be used to indicate the context of the log messages instead of the class name.
- Log lines are longer due to the
- Getting the method name & line number via throwing a new exception for every log statement causes additional overhead so you don’t want to use this for release builds.
If you’re using Timber for logging then here’s a Tree that’ll prefix your messages with the correctly formatted links to source:
In case you’re using
android.util.Log (or any other logging library) then run your log messages through