Android Log Example


Android Log provides ongoing details of our process & makes it easy for us to understand the scenarios happening behind the code. Logs are used extensively while development to understand the issues caused by errors, yet we should be sure that we have removed piles of log on releasing our App. In order to use Logs in android we need to import android.util.log.

This  tutorial will quickly guide on how to use Android Log for debugging purpose using LogCat. Using built in LogCat within Android Studio you will be able to monitor all the events of your application running on emulator or actual device.

Also check ADB Logcat Security Risk to understand importance of using logs properly.

Let us start locating LogCat View from Android Studio.


    • Below image depicts  Logcat View

AndroidStudio Logcat View



Various Methods we can use to display Logs for our App :


  • Log.e( TAG, MESSAGE ) : Error Log – used when worst happens to our App. Most of the times we need this  inside catch block to report the error in Log. (These logs are displayed in red)
  • Log.w( TAG, MESSAGE ) : Warning Log – If you suspect something suspicious yet not an error, use this method to show ongoing Warning message. It may not be a total disaster, neither a favourable outcome as well. (These logs are displayed in orange)
  • Log.i( TAG, MESSAGE ) : Information Log – These kind of Informative Logs are used to know about what happened last, Previous success state, some checkpoint level message, completion state, etc. – i.e. any kind of  informations we want to see at any time interval. (These logs are displayed in green)
  • Log.d( TAG, MESSAGE ) : Debug Log – As the name says, it lets you identify flow of your program while debugging. (These logs are displayed in blue)
  • Log.v( TAG, MESSAGE ) : Verbose Logs  are used to obtain minute details of our App. It is of the lowest priority. Too  much of usage may become complicated & reduce performance of our App. (These logs are displayed in black)
  • TAG, MESSAGE ) : WTF Log stands for “What a Terrible Failure” used to display some unwanted happenings, same as errors . (These logs are displayed in red)



  • Further we shall see how to use these methods inside our Activity Java File.


Source Code :


Now Let us work on Project : (Refer – Configuring Existing AndroidStudioProject) Log which you might have downloaded from above or you can follow the scripts below by copying it to implement  in your Project. To launch Downloaded project, Extract the zip, copy it into AndroidStudioProjects. Now from Android Studio click open Existing Android Studio Project and select the path to extracted file we just copied in AndroidStudioProjects directory. If Sync SDK path prompt comes just click OK and you are ready to work. If still you get error check for AndroidStudioProjects/Log/app/build.gradle , it will contain different SDK Version. Change it to SDK Version which you have.




Explaining above Code :

  • We have added methods as explained above, which will generate Logs based on various situations.



2. activity_main.xml : Layout file

  • Inside our activity_main.xml we have simply added a static TextView.




Filtering Logs based on TAG :

Filter in AndroidStudio Logcat View



Report Errors + Bugs & Become Insider for

We would like to hear you, if you find any error or misspelled phrase while reading our tutorials. By reporting mistakes through email to you could help other peers.