Linux logs and grep: find the clue in a log file
When a test fails on a server, the answer is often in a log. Learn to look at the end of a file, search it, and follow it live.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a ship's logbook. A ship's crew writes each event in a book with the time. After a storm, the captain reads the pages from that night.
The captain does not read the whole voyage. The captain looks for the time and the word storm.
A log file is that book. Tom, the tester at Daily List, a to-do list app, searches it for the time and the word error.
PLAIN WORDS · 1 in this section
- logbook
- a book where a captain writes down each day's events
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Finding the one line that explains a failure, like reading the logbook for the night of the storm.
- Time
- Level
- Word
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The logbook | The log file |
| The page for that night | The time range |
| The word storm | ERROR |
| Reading live | tail follow |
WHERE THIS PICTURE STOPS
- A logbook is written by hand, but a log is machine text.
- A captain knows the ship, but a tester may not know the app.
- A book has few pages, but a log can be huge.
HOOK
Time, level, word.
TELL A FRIEND
A logbook: find the night, then the word.
OFTEN MIXED UP WITH Reading logs for testers. That topic explains what logs are for. This one adds the commands to search and follow them.
PRACTISE AND KEEP
Sources for this topic — 1 source
- Market practice
GNU Grep manual (GNU Project) ↗ — GNU Project · GNU grep manual: -i ignores case, -r searches directories recursively and -n shows line numbers (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.