Android studio - Android Logcat viewer with new features
Published November 30, 2022Android studio has too many tools where each window has its specific use case. In this article we are going to discuss the Logcat window. Logcat window is used to print the log messages of current running applications. For example if the currently running application crashed and we want to see the cause for the crash, then this Logcat window will display all the info about the crashes. Logcat Window is going to help us to debug the output which will collect and view all the messages that our emulator/device throws. So, the Logcat tool is a very useful component for app development.
We can conclude that when we run our app in the emulator/ real devices, then we will see a lot of messages which will include all the information, verbose messages, and all the errors which will be generated while running our application. Example, if an application of about more (10000) lines of code gets an error. So, in that case the 10000 line codes, to find the error which line effected, Logcat helps us to displaying the error messages
Log Class
The Logcat prints the errors in the different types. Each type will have a different priority. To print the log messages Logcat window will use Log Class. This Log class has different methods to categorize the messages.
Below we can see different type of Log messages and their respected color to display on Logcat window
Log type |
Syntax |
Color |
verbose |
v(String, String) |
white |
debug |
d(String, String) |
green |
information |
i(String, String) |
blue |
warning |
w(String, String) |
yellow |
error |
e(String, String) |
red |
Android new Logcat Viewer
In the Android studio Dolphin version, the Logcat window introduced a new format of Log messages. This new Logcat will be an easy way to filter the messages to the android developers.
Create Multiple Log windows
We can now create multiple Logcat windows , by this feature we can easily filter the logs by different devices or queries.
To create a new Logcat window, clicking on the “+” icon will create a new window.
We can also split the window to filter the logs. Right-click on the window and choose Split right/Split down/Split left, so that a new Logcat window will be created.
Switch between windows
Logcat window has different view modes like Standard and Compact view. This we can achieve by click on Logcat format options
New Search based on Key and values
Previous Logcat we did search the logs by adding the string inside search box or regex format, but now in the new Logcat window we can search by key-value pair
With this new log search feature will make the accurate search of the logs and we can get the history of the previous searches also.
Bookmarks the Messages
We can make Bookmark the search queries with key-values, so that next time we can easily find them inside the filter dropdown on the top section
Filter the messages based on key values
The query search given options of different key like
- Package: Filter the Logs based on package
- tag: Matches against the tag field of the log entry
- message: Filter logs by the given message
- level: We can filter the logs by level like debug,verbose,info,warning and error.
- Level:debug
- Level:info
- Level:verbose
- Level:warning
- Level:error
Like this there are other keys we can filter the logs like
age:<number><unit>
-
<number> is an integer
-
<unit> is one of s, m, h, & d (seconds, minutes, hours, and days)
Ex: age:30s
age:5m
age:3h
Age:1d
is Filter
Is:value
Below are the few supported queries
key:value |
Match if the field contains value |
-key:value |
Match if the field doesn't contains value |
key~:value |
Match if the field matches the regex value |
-key~:value |
Match if the field doesn't match the regex value |
key=:value |
Match if the field is exactly value |
-key=:value |
Match if the field is not exactly value |
Conclusion: In this article we covered what is android logcat window and what is the new features of Android logcat viewer
Keywords:
Android studio Logcat
Android studio Logcat viewer
Studio Dolphin logcat
Android studio save logcat
Android studio logcat filter
Android studio logcat app
Android studio logcat not showing
Article Contributed By :
|
|
|
|
173 Views |