Hello Guys !!! Hope you all doing well !!!
Today I am going to discuss a very hot topic in Android Development life cycle and it is
What Log message contains:-
Each message in the log consists of
1. Application log
Log format on Android
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 it are not standardized(i.e. some may be ROM-specific). I am putting some of common here.
To capture Logs from the android devices/emulator Below is the some command line tool. In real life project there are log capture application/tool used to capture the logs on user device and shared it back to Developer/maintainer for analysis .
Today I am going to discuss a very hot topic in Android Development life cycle and it is
Logs Analysis.
As an Android developer, all of you know Logs analysis is a phase of development and we encounter it time to time.
But Log Analysis is main challenging thing for code maintainer or Support Engineer.
As an Android developer, all of you know Logs analysis is a phase of development and we encounter it time to time.
But Log Analysis is main challenging thing for code maintainer or Support Engineer.
Once Any Android product launched in market and customer start using it. Then real scenario bugs/issue start coming and it is main Job for Support Engineer/Project maintenance engineer to analysed the Bug/issue with provided set of logs.
All we know “How It is challenging”.
So today I am going to shed some light on it. First We start with type of Log available on Android Eco-system :-
So today I am going to shed some light on it. First We start with type of Log available on Android Eco-system :-
- Application Log
- System Log
- Event Log
- Radio Log
- a kernel driver and kernel buffers for storing log messages
- C, C++ and Java classes for making log entries and accessing the log messages
- Logcat (a standalone program for viewing log messages )
- DDMS (ability to view and filter the log messages from the host machine)
- main - the main application log
- events - for system event information
- radio - for radio and phone-related information
- system - a log for low-level system messages and debugging
overview of Android logging System (image by Tetsuyuki Kobabayshi, of Kyoto Microcomputer Co.) |
What Log message contains:-
- A tag indicating the part of the system or application that the message came from
- A timestamp (at what time this message came)
- The message log level (or priority of the event represented by the message) and
- The log message itself(detail description of error or exception or information etc)
What Each Log Type Contains:-
- use android.util.Log class methods to write messages of different priority into the log
- Java classes declare their tag statically as a string, which they pass to the log method
- The log method used indicates the message "severity" (or log level)
- Messages can be filtered by tag or priority when the logs are processed by retrieval tools (logcat)
- Use the android.util.Slog class to write message with different priority with its associated messages
- Many Android framework classes utilize the system log to keep their messages separate from (possibly noisy) application log messages
- A formatted message is delivered through the C/C++ library down to the kernel driver, which stores the message in the appropriate buffer(system buffer)
- Event logs messages are created using android.util.EventLog class, which create binary-formatted log messages.
- Log entries consist of binary tag codes, followed by binary parameters.
- The message tag codes are stored on the system at: /system/etc/event-log-tags.
- Each message has the string for the log message, as well as codes indicating the values associated with (stored with) that entry.
4. Radio log
- Used for radio and phone(modem) related information
- Log entries consist of binary tags code and message for Network info
- Logging system automatically routes messages with specific tags into the radio buffer
below is common log format in android
tv_sec tv_nsec priority pid tid tag messageLen Message
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 it are not standardized(i.e. some may be ROM-specific). I am putting some of common here.
- /data/anr : Dalvik writes stack traces here on ANR, i.e. "Application Not Responding" aka "Force-Close"
- /data/dontpanic : contains some crash logs including traces
- /data/kernelpanics :- Stores "kernel panic" related logs
- /data/tombstones :- may hold several tombstone_nn files (nn is a number from 0 to 10 and after 10 again repeat it)
To capture Logs from the android devices/emulator Below is the some command line tool. In real life project there are log capture application/tool used to capture the logs on user device and shared it back to Developer/maintainer for analysis .
- adb logcat (shows all type logs for current android system
- adb logcat -v threadtime (it will include date and time)
- adb logcat -v threadtime > logfile.txt (Store logs in logfile.txt)
Useful filter patterns
You can use below filter in your adb command to filter logs. You can also use this filter to search your logs file(logs provided by user device).
You can use below filter in your adb command to filter logs. You can also use this filter to search your logs file(logs provided by user device).
- adb logcat -f <output_file> Save all logs into a file
- adb logcat "*:E" Get all errors and fatals
- adb logcat | grep -i "foo.example." #get all logs related to “foo.example.*” tagname
- adb logcat "application_or_tag_name:*" "*:S" Get all logs by application name
- adb logcat -b events "gsm_service_state_change" "*:S" Get all GSM state changes
- adb logcat -b radio Get all Radio events
Log Analysis
Till now we get all the fundamental exposure of Android Logging System. Now the time to analyse the logs coming from your application or end user. Here we can divide log analysis in two part
Till now we get all the fundamental exposure of Android Logging System. Now the time to analyse the logs coming from your application or end user. Here we can divide log analysis in two part
- Debug Log :- logs file coming during development and testing phase
- Production Log:- Logs file coming directly from end user.
- "Useful Filter Patterns" and
- By using Some Tool (example LogRabit, GoogleLogTool and SonyLogTool)
But one thing is good Every android analysis (end user issue/bug log) gives you a 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 comment box. It will energize me a lot.
Thanks
Aryo
Happy Coding!!!!
0 komentar:
Posting Komentar