Skip to content

Android Logcat Log.v(), Log.d(), Log.i(), Log.w(), Log.e() – When to use each one?

  • by

Android Logcat is a part of application development to check results, errors,s, etc in an Android studio. Android app developers can thus get all logs and messages from their remote (or emulated on the virtual device) device. It allows to view, filter, and collects all application logs.

Android Logcat Log.v(), Log.d(), Log.i(), Log.w(), Log.e() - When to use each one?

In Android Studio, you can find at the bottom there is the button “Logcat”. Press it, the new toolbox will be open where you can use the “device option” and “application option” drops down. This option will null if your app is not running on a device or emulator.

Once you selected the option you can see all application log messages in this area. You can select any one filter option from a drop-down menu as below mentioned.

  • Log.v() – Verbose log
  • Log.d() – Debug log
  • Log.i() – Info log
  • Log.w() – Warning log
  • Log.e() – Error log

Selecting the option to give you filtering the messages, for an example, you want only to see the error.

Manually use of dubbing is for debugging and find application error.

Android Logcat in Details 

Here are details of Android Logcat where and which type of log you have to use and how to use.

Log.v() : Use this when you want to go absolutely nuts with your logging. If for some reason you’ve decided to log every little thing in a particular part of your app, use the Log.v tag.

Log.d(): Use this for debugging purposes. If you want to print out a bunch of messages so you can log the exact flow of your program, use this. Also If you want to keep a log of variable values.

Log.i(): Use this to post useful information to the log. For example: that you have successfully connected to a server. Basically, use it to report successes.

Log.w(): Use this when you suspect something shady is going on. You may not be completed in full-on error mode, but maybe you recovered from some unexpected behavior. Basically, use this to log stuff you didn’t expect to happen but isn’t necessarily an error. Kind of like a “hey, this happened, and it’s weird, we should look into it.”

Log.e(): This is for when bad stuff happens. Use this tag in places like inside a catch statement. You know that an error has occurred and therefore you’re logging an error.

Leave a Reply

Your email address will not be published. Required fields are marked *