Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

DartintermediatecliAI generated

Dart CLI Log File Analyzer

Build a Dart command-line tool that reads web server log files (Apache or Nginx) and prints a clear summary: how many requests there were, the share of each status code, the most requested pages, the busiest IP addresses and the traffic per hour. It reads files line by line as a stream, so even multi-gigabyte logs don't fill up memory, and it can filter by date range and export the report as JSON or CSV for other tools. You'll learn regular expressions, streams and async code in Dart, parsing dates, aggregating data with maps, command-line options with the args package, and testing.

Estimate
~9h
Steps
6
Completed by
0
Proposed by
codeseed.app

Dart SDK · dart:io · args package

Project roadmap

  1. 01

    Parse one log line

    ~1.5h

    Create a project with dart create -t console and add the args package. Write a LogEntry class and a parser using a RegExp for the combined log format, extracting the IP, time, method, path, status, size, referrer and user agent. Convert the time (such as 10/Oct/2026:13:55:36 +0000) to a UTC DateTime. Return null for lines that don't match. Done when: unit tests parse valid lines correctly and reject broken ones.

  2. 02

    Stream the file

    ~1.5h

    Read the log with File.openRead(), decode it with utf8.decoder and split it with LineSplitter, processing each line as it arrives. Support reading .gz files with gzip.decoder, and reading from standard input when the file name is -. Count malformed lines separately. Done when: a large log file is processed with low, steady memory use.

  3. 03

    Aggregate the statistics

    ~1.5h

    Create a Stats class that updates counters as entries arrive: total requests and bytes, counts by status code and status class (2xx, 3xx, 4xx, 5xx), counts by path (without query strings) and by IP, and requests per hour. Done when: the totals for a small sample log match counts made by hand.

  4. 04

    Print the report

    ~1.5h

    Print a formatted report: the time range covered, totals, status codes with percentages, the top 10 paths and IPs (with a --top option to change 10), and requests per hour as a simple text bar chart. Align the columns with padLeft and padRight. Done when: the report is easy to read and its numbers match the Stats.

  5. 05

    Add filters and export

    ~1.5h

    Add options: --from and --to dates, --status (for example 5xx) and --path-prefix to filter entries, and --format text, json or csv. JSON output contains the full statistics, and CSV writes one row per path. Validate every option and print the usage for invalid values. Done when: filtering by date changes the report, and --format json produces valid JSON.

  6. 06

    Test it

    ~1.5h

    Write tests with package:test: the parser (valid lines, malformed lines, time zones), aggregation on a fixture log, filters, and JSON output. Add a test that runs the whole tool on a fixture file and checks the output. Done when: dart test passes.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~9h · 6 steps

Tech stack

Dart SDKdart:ioargs package