I found an option to store logs: Settings
-> System
-> Advanced
-> Developer options
-> Store logger data persistently on device
.
I wonder where these logs are saved and how we retrieve them. I searched online but found no result.
logd
is the logging daemon on Android which mainly covers the functionality of its desktop counterpart syslogd, but also includes klogd and partially auditd to get logs from SELinux subsystem of kernel. However logd
just reads from different memory buffers (in RAM) and doesn't save to persistent memory (files) by default. We can use commandline tools logcat
and log
to read/write from/to logd
respectively. Read here more about memory buffers - main
, system
, radio
, events
, and crash
.
If one needs persistent logs as files, a separate sub-service (available on userdebug
and eng
builds only since Oreo (1)) named logcatd
(logcat
daemon which itself reads from logd
) can save them to filesystem in /data/misc/logd/
(not accessible without root). Behavior of the service on boot is controlled by properties logd.logpersistd.enable
and persist.logd.logpersistd
(2). Or to manually start/stop the service shell scripts /system/bin/logpersist.[start|stop]
can be used.
The option “Store logger data persistently on device” in “Developer Options” also controls the same service using property persist.logd.logpersistd.buffer
. From official documentation:
Store logger data persistently on device: Select the type of log messages you want to store persistently on the device. Options are off, all, all but radio, or kernel only.