Read and Understand logs
What is the efficient debugging way? reading logs. Manually testing each options makes things difficult and time-consuming. If we read the logs we get to know why we are receiving such unexpected outcome. Because \(n\)-different factors can lead to same outcome.
Logs have too much information not all are necessary to understand why we are receiving specific output.
Steps
- First answer the question : What decision did the system make that surprised me?
- Ask:
- What system produced these logs?
- What subsystems exist inside it?
example: for a mail synchronization issue we look for MailSyncWorker→ syncingMessagingController→ high-level mail logicNotificationController→ notificationsPushController→ push vs pollingAndroid WorkManager→ scheduling
-
List down the events and their timeline (with search)
Time What happened 07:32:39 App process starts 07:32:39–47 Background mail sync runs … … - Separate signals form noise
- Verbs about decisions (D)
- Words like:
start,stop,clear,disable,success,cancelled,no new,already present.
Example signal:
7:32:39 Scheduling work ID ... MailSyncWorker 7:32:39 Executing periodic mail sync 7:32:39 Running command 'checkMail' 7:32:39 Starting mail check 7:32:40 Synchronizing account .. 7:32:40 Connecting to imap.gmail.com 7:32:42 authenticated (Success) 7:32:45 EXAMINE "INBOX" 7:32:46 Remote message count for folder INBOX is 2 .... -
Track state transition. Build the mental model of the workflow from such logs
12-24 07:32:47.xxx 8541 8577 D ImapSync: Have 0 unsynced messages
Ignore the irrelevant logs that are not specific to your issue. like
OEM,UI,darkmode,library loading, …
Breakdown of Log
12-24 → Date (MM-DD)
07:32:47.xxx → Time (HH:MM:SS.milliseconds) — local device time
8541 → Process ID (PID)
8577 → Thread ID (TID)
D → Log level (DEBUG)
ImapSync → Component / class emitting the log
Message → Actual event
Log Levels Reference
| Level | Read when | Why |
|---|---|---|
| V | Rarely | Too detailed |
| D | Always | Real behavior |
| I | Always | Phase confirmation |
| W | Carefully | Unexpected but handled |
| E | Immediately | Failure |
| F | Drop everything | Crash |