
- #ANDROID STUDIO LOGCAT WINDOW ANDROID#
- #ANDROID STUDIO LOGCAT WINDOW CODE#
- #ANDROID STUDIO LOGCAT WINDOW WINDOWS#
#ANDROID STUDIO LOGCAT WINDOW ANDROID#
Also sometimes Android system logs can help you figure out what's going on. It will record all the activity with infinite scroll history and will be helpful for transient and hard to reproduce crashes. I also suggest always having an unfiltered Logcat window always running.
#ANDROID STUDIO LOGCAT WINDOW WINDOWS#
Try to use other tools such as Facebook Flipper or simply dedicated terminal windows Use a TerminalĪs you pay more attention to logging, using dedicated terminal windows will become obvious.įirst, you will be able to open several logging windows.
#ANDROID STUDIO LOGCAT WINDOW CODE#
Use more than Android Studio Log ViewĪlthough the Logcat tool window is one click away from your code and provides convenient filtering features, you may find it a little bit limited for advanced usage: In other words don't give in to the siren song and keep-it super boring and simple.

It should be enough to get more context on an inconsistent state that you can't reproduce. Remote logging is your friend in this situation.ĭid you know that Firebase Crashlytics provides a way to log Non-fatal exceptions? Sometimes problems only happen on customer devices and you may need contextual information to figure out what is going on. Since this can influence the behavior of your app, it is crucial to have this information to interpret the logs. In addition to the previous point, also log dynamic configuration at startup and when it is changed. If you have a base Fragment inherited by all your Fragments (and you should!) use it to log these events.

You should always be logging this kind of information. Lots of Android apps bugs and mis-behaviors are related to the Android lifecycle. This file can also contain other definitions for the module, such as dependency injection definitions. ++code> const val TAG = "mga.user"++/code> You can add a ++code>module.kt++/code> at the root of a feature package containing a const like You may use a pattern like ++code>.++/code>įor instance for My Good App (MGA), you would define: It can also lead to tag length greater than 23, which gets truncated in output. It also makes filtering more difficult based on this tag, because your feature will often be implemented with multiple classes.

Suggestions of usage and flow rate for each log level Meaningful TaggingĪlthough it's a popular pattern to use the class name as the log tag, I suggest you don't use a class name for your tag.įirst it's leaking implementation details. For instance, you may target this kind of pace per log level : You should try not to flood the most important log levels. Timber is a popular library which will allow you to do exactly that. This will allow you to easily disable the logs in production build, redirect them to another output, or decorate the lines if needed. Of course you can use the built-in Log class and its convenient static methods, ++code>d(),e(),i()++/code> ?Īn option is to create your own wrapper for this class and inject it into your classes. Here are some tips to do better logging on your Android App. I suggest that logs can be useful on a daily basis if done correctly. You write tons of throwaway log lines such as ++code>"being here"++/code>, ++code>"user=23939"++/code>, etc? and delete everything as soon as you understood the root cause of the bug.

Logging can sometimes be seen as the tool to be used as a last resort.
