In Android, we are able to log info by using the static methods provided by the final class Log. This class is part of the android.util package.
Available methods
Method signature
If we log the next messages, the result from Logcat is present in the picture below.
In Android Studio > Settings > search Android Logcat and from there we are able to customise the color of the logged messages from Logcat.
When and what to log?
It is recommended to create different build flavors depending on the available server environments. For example, you could have a dedicated flavor for dev, QA, pre-prod, prod. Based on this classification also the logging strategy is changed.
On the test environments is ok to log many details in order to make sure everything is working properly. In the production environment, it is recommended to log only the most relevant info in order to not affect the performance. Also, you should take care not to log sensitive data like emails, phone numbers, personal ids, and so on.
If you want to learn more about logging you could check a dedicated episode on the Fragmented Podcast.
Enjoy and feel free to leave a comment if something is not clear or if you have questions. And if you like it please share!
Thank you for reading!
Originally published at http://magdamiu.com on October 19, 2020.
Top comments (0)