foreword
Recently, Android Studio has automatically updated the built-in Logcat tool, and the overall appearance and usage have become completely different from before. At first I thought it was because I pressed some button that I shouldn't have pressed and broke the Logcat, but later I realized that it was caused by the version update. The new version of Logcat uses commands to filter information, and different log levels are displayed in different colors, which is more usable than the old version. This blog will briefly introduce the usage of the new version of Logcat
1. Filter package name
The new version of Logcat uses package:
to filter logs in different packages, where mine
indicates the current package
2. Filter by log level
Filtering by log level is the most commonly used function in Logcat, and the new version of Logcat uses level:
to filter log levels. According to the different levels of the log, there are the following options:
- level:VERBOSE: show all logs
- level:DEBUG: Display debug log
- level:INFO: display general information
- level:ERROR: display error log
- level:ASSERT: Display assertion information
As you can see, different filtering commands only need to be separated by spaces .
3. Keep logs for a specified time
The new version of Logcat also provides the function of filtering logs at a specified time, such as
age:10s
The above command indicates that the output starts from the log 10s ago, where s means seconds, and it is easy to think that m means minutes (minute), and h means hours (hour).
4. Common commands for filtering information
message:
for filtering information
tag:
for filtering tags
line
: Filter logs with row information, which tag:
is message
the union of and
5. Some special operations
Seeing this, you might say, well, you can only do simple filtering. Suppose I want to filter logs CXK
that ? How about using regular expressions? These new versions of Logcat take it all into account!
We simply enter in the input box of Logcat, and the following prompt message
will pop up
We see that the prompts that pop up are message:
, message~
, -message
and -message~
. You can see that there are some more symbols message
before and after . Now let me explain the functions of these symbols:
-
: Negate the filtering result of the current label~
: Use subsequent regular expressions for filtering on the current tag
As smart as you are, you must be able to think -xxx~
that xxx
the result of using a regular expression on the label is negated~~