Android logs caption

As an Android developer, all of you know Logs analysis is a phase of development and we encounter it from time to time.
But Log Analysis is the main challenging thing for code maintainer or Support Engineer.

Once Any Android product launched in the market and customers start using it. Then real scenario bugs/issues start coming and it is the main Job for Support Engineer/Project maintenance engineer to analyze the Bug/issue with provided set of logs.

First We start with the type of Log available on Android Eco-system:-

  • Application Log

Android logging system consists of:

  • a kernel driver and kernel buffers for storing log messages

Android Log Buffer/container

  • main — the main application log

What Log message contains:-

Each message in the log consists of

  • A tag indicating the part of the system or application that the message came from

What Each Log Type Contains:-

1. Application log

  • use android.util.Log class methods to write messages of different priority into the log

2. System log

  • Use the android.util.Slog class to write a message with different priority with its associated messages

3. Event log

  • Event logs messages are created using android.util.EventLog class, which creates binary-formatted log messages.

4. Radio log

  • Used for radio and phone(modem) related information

Log format on Android

below is common log format in android

tv_sec   tv_nsec     priority     pid    tid     tag     messageLen       Message

tag: log tag
tv_sec & tv_nsec: the timestamp of the log messages
pid: the process id of where log messages come from
tid: the thread id
Priority value is one of the following character values, ordered from lowest to highest priority:
V — Verbose (lowest priority)*
D — Debug*
I — Info*
W — Warning*
E — Error*
F — Fatal*
S — Silent (highest priority, on which nothing is ever printed)

Log-File locations
There are several directories where logs (including those from crashes) stores and they are not standardized(i.e. some may be ROM-specific). I am putting some common here.

  • /data/anr : Dalvik writes stack traces here on ANR, i.e. “Application Not Responding” aka “Force-Close”

‘Log’ command-line tool
To capture Logs from the android devices/emulator Below is some command-line tool. In real-life projects, there are log capture applications/tools used to capture the logs on the user device and shared it back to the Developer/maintainer for analysis.

  • adb logcat (shows all type logs for the current android system

Useful filter patterns
You can use the below filter in your adb command to filter logs. You can also use this filter to search your logs file(logs provided by the user device).

  • adb logcat -f <output_file> Save all logs into a file

Log Analysis
Till now we get all the fundamental exposure of the Android Logging System. Now the time to analyze the logs coming from your application or end-user. Here we can divide log analysis in two-part

  1. Debug Log:- logs file coming during development and testing phase

So guess which one is difficult Production one Right? So what is the best approach to debug and get the desired info from the captured logs? As I discussed above, We can do it by using

So in the last Android log analysis is continuous learning and utilizing your experience process. Personally I analyzed logs via relevant filter and tool with my past experience.

But one thing is good Every android analysis (end-user issue/bug log) gives you new learning and experience. So keep it doing and enjoy your life as a coder and maintainer of android system😎😎😎

Please put your comments in the comment box. It will energize me a lot.

Thanks for the support!

A developer is responsible for developing a framework and system applications for devices powered by the Android operating system.