In Android Logcat Monitor is available under Android Monitor , which helps us to see and write the messages during our application execution cycle. Android Logcat Monitor shows the system messages like the exception occurred during application execution or we need to print some output to logcat monitor and we can write all this kind of messages using Log class provided by Android system.
Logcat monitor displays messages in real time and also keeps the history of messages generated by the system and also keeps history until we delete it. By default logcat monitor shows messages of most recent run application.
Logcat monitor displays messages in real time and also keeps the history of messages generated by the system and also keeps history until we delete it. By default logcat monitor shows messages of most recent run application.
Logcat Message Format
Every system generated android log message has a tag and priority associated with it. Tag is used to identify the component from which message is generated. A user can also define his own tags which can be a simple string that can help to identify the issue properly such as a class name or a method name.
To print some message using Android Log class there are some methods which receives three parameters one is Tag, second is Message and third param is throwable exception to log.. Tag is used to identify the class or method or component which generated the message and Message is description of either error or output.
There are following five methods that are being used to print some messages or outputs-
- Verbose (v)- Show all log messages (the default).
- Debug (d)- Show debug log messages that are useful during development only, as well as the message levels lower in this list.
- Info (i)- Show expected log messages for regular usage, as well as the message levels lower in this list.
- Warn(w) - Show possible issues that are not yet errors, as well as the message levels lower in this list.
- Error(e) - Show issues that have caused errors, as well as the message level lower in this list.
- Assert (a)- Show issues that the developer expects should never happen.
In the figure above we can see log messages in android log monitor. We can also filter the messages we want to see.
Here is an example that shows how to call the log methods -
Method Format - Log.e(Tag,Message)
Example - Log.e("oncreate","Method is called");
we can use this to print message "Method is called" in Logcat to see whether oncreate method of activity is called or not. In the same way we can call the methods for other types also like the below -
Log.v()
Log.d()
Log.i()
Log.w()
Log.e()
That is enough to get started with the Android Logcat Monitor .
No comments:
Post a Comment