Commands · reference

vmlab logs

4 min read · 2026-09-02 · vmlab 0.9

vmlab logs dumps or follows the JSON-line logs vmlab writes under its state directory: the lab's event log, one VM's QEMU and serial logs, or one container's console log. It reads the files directly, so it works with no daemon running and after a lab has been stopped. The events it shows are described in Events and handlers and listed in Events; the files themselves are in Files and directories.

sh
vmlab logs [OPTIONS] [TARGET]
OptionMeaning
[TARGET][lab/][machine]. Default: the lab of the current directory.
-f, --followKeep following.
-n, --lines <LINES>Lines of history to show. Default: 100.
-o, --output <OUTPUT>Output format: pretty, human-readable and colorized on a terminal, or jsonl, one raw event per line. Default: pretty.
-h, --helpPrint help.

With no target the command shows the current lab's events.jsonl. A lab/vm target shows that VM's qemu.log and serial.log, and a lab/container target that container's console.log. A bare name is a machine when the current directory's lab declares it and a lab name otherwise, so vmlab logs ad-lab works from anywhere. When no matching log file exists the command refuses with no logs found.

Each file is read from its end, so a serial log of tens of megabytes costs only the last --lines. When more than one file matches, each section is introduced with a ==> path <== header. Event lines in pretty form show the local time, the event name, and the flattened data; QEMU, serial and console lines are printed as they are in both formats. With --follow the command polls the first matching file every half second and prints new lines until Ctrl-C.

sh
vmlab logs -f
vmlab logs -n 500 -o jsonl ad-lab | jq 'select(.event == "vm.state")'
vmlab logs ad-lab/dc01

Exit status is 0 on success. The command sends no daemon request, so every failure exits 1: no lab in the current directory and no target, a lab file that does not load, no log file for the target, or a file that cannot be read while following.