This article will introduce how to get logcat from ADB command in Android.
1. How to get logs
The adb logcat
command prints out the logs from the device.
Note that there are system, main, and event log buffers where logs are stored, and this command by default prints out both the system and main logs. and there are log levels like VERBOSE, DEBUG, ERROR, FATAL.
In this example, The logs here are logs with levels other than VERBOSE, such as DEBUG, INFO, WARNING, ERROR, and FATAL.
$ adb logcat
06-24 21:21:49.412 5258 5258 D NetworkSecurityConfig: No Network Security Config specified, using platform default
06-24 21:21:49.426 5162 5239 I LogSaver: LogSaver new instance with filename: carrier_services
06-24 21:21:49.440 271 4782 W android.hardware.audio.service.ranchu: TinyalsaSink::write:125 pcm_write was late reading frames, dropping 22131 us of audio
...
Please refer to the following for the priority of log levels.
- V: Verbose (lowest priority)
- D: Debug
- I: Info
- W: Warning
- E: Error
- F: Fatal
- S: Silent (highest priority)
2. How to get logs of a specific tag
If you enter the option -s TAG
in the command, only the log of the TAG will be output.
$ adb logcat -s ActivityManager
06-24 21:22:00.046 502 533 W ActivityManager: Slow operation: 78ms so far, now at startProcess: done updating pids map
06-24 21:22:00.941 502 1600 I ActivityManager: Killing 4176:com.android.dialer/u0a99 (adj 985): empty for 3218s
06-24 21:22:01.041 502 1650 W ActivityManager: Unable to start service Intent { act=com.android.vending.contentfilters.IContentFiltersService.BIND pkg=com.android.vending } U=0: not found
3. How to get logs of a level or higher levels
If you enter the option *:W
in the command, only logs with Warning log level or higher will be output. (i.e. Warning, Error, Fatal, and Silent.)
$ adb logcat *:W
06-24 21:23:49.094 5891 5891 W d.process.acor: Unexpected CPU variant for X86 using defaults: x86
06-24 21:24:11.296 502 647 E ClipboardService: Denying clipboard access to com.android.chrome, application is not in focus nor is it a system service for user 0
06-23 22:56:09.422 0 0 W healthd : battery l=100 v=5000 t=25.0 h=2 st=4 c=900000 fc=300000 cc=10 chg=
06-24 21:24:28.293 475 475 E netmgr : qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:network' service: Invalid argument
...
The following command prints only log entries of Error or higher.
$ adb logcat *:E
06-24 21:28:28.966 479 479 E wifi_forwarder: RemoteConnection failed to initialize: RemoteConnection failed to open pipe
06-24 21:29:28.410 475 475 E netmgr : qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:network' service: Invalid argument
06-24 21:29:28.410 475 475 E netmgr : Failed to open QEMU pipe 'qemud:network': Invalid argument
...
4. How to get "events" logs
The adb logcat
command only outputs the main and system buffer logs by default, and does not output the logs from the event buffer.
If you want to only get the event logs, then you need to enter -b events
option.
$ adb logcat -b events
06-24 21:29:32.781 908 908 I service_manager_stats: [100,62,460262]
06-24 21:30:42.169 502 531 I am_pss : [4874,10124,com.android.chrome:privileged_process0,26935296,10887168,0,147382272,0,12,5]
06-24 21:30:59.260 502 531 I device_idle_light_step:
...
4. How to get all logs including "main", "system", "events"
If you want to all logs including "main", "system", "events", then you need to enter the option -b all
.
$ adb logcat -b all
5. How to clear the log buffer
The following command clears all stored log buffers. It is used to make sure that logs stored from previous times are not outputted.
$ adb logcat -c
6. How to get the most recent logs
The -t number
command prints only the number of lines from the most recent log.
In this example, The following command prints only the 10 most recent lines of the log.
$ adb logcat -t 10
--------- beginning of main
06-24 21:34:29.193 479 479 E wifi_forwarder: qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:wififorward' service: Invalid argument
06-24 21:34:29.193 479 479 E wifi_forwarder: RemoteConnection failed to initialize: RemoteConnection failed to open pipe
06-24 21:35:28.585 475 475 E netmgr : qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:network' service: Invalid argument
06-24 21:35:28.586 475 475 E netmgr : Failed to open QEMU pipe 'qemud:network': Invalid argument
06-24 21:35:29.210 479 479 E wifi_forwarder: qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:wififorward' service: Invalid argument
06-24 21:35:29.210 479 479 E wifi_forwarder: RemoteConnection failed to initialize: RemoteConnection failed to open pipe
06-24 21:36:28.595 475 475 E netmgr : qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:network' service: Invalid argument
06-24 21:36:28.596 475 475 E netmgr : Failed to open QEMU pipe 'qemud:network': Invalid argument
06-24 21:36:29.227 479 479 E wifi_forwarder: qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:wififorward' service: Invalid argument
06-24 21:36:29.227 479 479 E wifi_forwarder: RemoteConnection failed to initialize: RemoteConnection failed to open pipe
Related Posts
- How to download and build Android 13, AOSP
- Notification permission request, pop up notification in Android 13
- Resolve `Access blocked: ComponentInfo` error on Android 13
- Fix error "android gradle plugin requires java 11 to run. you are currently using java 1.8."
- Android - Vibration, Vibrator, VibrationEffect example
- How to get phone number in Android
- How to create Bugreports and Logcat with ADB in Android
- Clear application user data with ADB in Android
- How to disable/enable apps with ADB in Android
- How to find PID of a package with adb in Android
- How to grant/revoke permissions with adb in Android
- How to install an apk(app) with adb in Android
- How to kill a process/package from ADB in Android
- How to transfer files using adb push/pull command in Android
- How to capture the screen from adb in Android
- How to uninstall/install system apps from adb in Android
- How to change Settings values from adb in Android
- How to Factory reset with ADB in Android
- How to get logcat from ADB command in Android
- How to capture Heap Dump from app with ADB in Android
- How to force stop an app with adb in Android
- How to start/stop a service from adb in Android
- How to send/broadcast an intent from adb command in Android
- How to start an activity from adb in Android
- How to generate input from adb in Android
- How to check SQLite DB table in Android Studio
- How to get memory info and thread list from adb in Android
- Android - Uri, Scheme and SSP(Scheme Specific Part)
- How to parse a xml file with XmlResourceParser in Android
- Android - Signing an apk with Platfom key
- How to fix "Cleartext HTTP ... not permitted" for Android development
- How to fix "kvm permission denied" for Android Emulator
- Using ADB over Wifi for Android development