Search code examples
androidlogcatandroid-logcat

How does Android logcat work?


How does logcat works? Does it output the logs only when connected to a reader else it redirects everything to /dev/null? I'll follow up with a different question based on this. Thank you


Solution

  • In older versions of Android, there's a set of circular buffers in the kernel. Each log (main, slog, events, radio) has its own buffer. The original size was 64K, but that was increased in subsequent releases.

    Recent versions of Android have moved toward user-space handling of logging.

    Log collection is happening continuously, with older logs overwritten by newer logs.

    The logcat command reads from one or more circular buffers, e.g. the default command reads from the main and system logs and interleaves them by timestamp. It isn't running unless you run it.