BeginnerCoder

Lesson 18 — Mini project: log parser

Read the server's diary

Servers write logs: one line per event, usually starting with a level like INFO, WARN or ERROR. A small parser can count lines per level to show if something is wrong. split(" ")[0] takes the first word of a line.

"ERROR db down".split(" ")[0];   // "ERROR"

Why it matters: when the site breaks at night, counting errors in logs is the first thing you do.

Want it another way?
Task

Count lines per level into counts, then log INFO, WARN and ERROR counts.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with Node.js Foundations

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.