Android Logging System
This article describes the Android logging system
The Android system has a logging facility that allows systemwide logging of information, from applications and system components. This is separate from the Linux kernel's own logging system, which is accessed using 'dmesg' or '/proc/kmsg'. However, the logging system does store messages in kernel buffers.
The logging system consists of:
* a kernel driver and kernel buffers for storing log messages * C, C++ and Java classes for making log entries and for accessing the log messages * a standalone program for viewing log messages (logcat) * ability to view and filter the log messages from the host machine (via eclipse or ddms)
There are four different log buffers in the Linux kernel, which provide logging for different parts of the system. Access to the different buffers is via device nodes in the file system, in /dev/log.
The four log buffers are:
* main - the main application log * events - for system event information * radio - for radio and phone-related informatio * system - a log for low-level system messages and debugging
Up until 2010, only the first three logs existed. The system log was created to put system messages in a separate buffer so that a single verbose application couldn't overrun system messages and cause them to be lost.
The kernel driver for logging is called the 'logger'. See Android logger
You can use the 'logcat' command to read the log. This command is located in /system/bin in the local filesystem, or you can access the functionality using the 'adb logcat' command.
Documentation on the use of this command is at: http://developer.android.com/guide/developing/tools/adb.html
Some quick notes:
- Log messages each have a tag and log level.
- You can filter the messages by tag and log level, with a different level per tag.
- You can specify (using a system property) that various programs emit their stdout or stderr to the log.