What is the Log

Log is a tool used by Android programs to print logs. Compared with the default console (println) output,Log supports hierarchical filtering of logs to facilitate filtering by keyword.

Based on the sample

  1. code
Log.v("MainActivity"."Print general information")
Log.d("MainActivity"."Print debug information")
Log.i("MainActivity"."Print prompt message")
Log.w("MainActivity"."Print a warning message")
Log.e("MainActivity"."Error message printed")
Copy the code
  • Log.v is used to print general logs. The value is verbose and has the lowest priority.
  • Log.d is used to display debugging information, which is used to confirm problems during development. The level is DEBUG, and the display priority is higher than verbose.
  • Log. I: displays important information at the info level, which has a higher priority than DEBUG.
  • Log.w, which prints a warning message indicating that a situation requires attention. The level is WARN, which has a higher priority than INFO.
  • Log.e: displays error information. It indicates that a serious problem occurs and should be rectified as soon as possible. When displayed in Logcat, it is generally red (all other levels of logs are gray).
  1. View the print result:

View the printed result in the Logcat window. Logcat main interface:

  • Area 1 displays a list of connected devices (including Android emulators and real phones). If multiple devices are connected, select the correct device from the list.
  • Zone 2 displays a list of debuggable applications running on the device. If “Show Only Selected Application” is selected in zone 5, only the logs of the selected applications are displayed.
  • Area 3 displays log levels. The higher the level is, the fewer logs are displayed. The lower the level is, the more logs are displayed. Levels: Verbose “Debug” Info “Warn” Error.

Note: There is also an Assert in the level list. According to the official documentation, log. WTF prints a higher level than Error, but the actual log. WTF prints Error.

  • Area 4 is used to filter logs by entering keywords.
  • Area 5 is used to determine whether the input information in area 4 is a regular expression.
  • Area 6 is used to select the filtering mode

  • Show Only Selected Application indicates that only the logs of the specified application are displayed.
  • Firebase is a basic service platform for Android development provided by Google. This option is used to display firebase-related logs.
  • “No Filters” indicates that No filtering is done.
  • Edit Filter Configuration opens a new screen for customizing new filters.

Example Print result:

About me

Xiamen university computer professional | huawei eight years senior engineer Ten years software development experience, 5 years experience in teaching programming training Currently engaged in the teaching of programming, software development, software class graduation design guidance. All programming materials and open source projects can be found at juejin.cn/post/700279…