MacOS – Tail multiple log files

logsmacostailterminal

I have an application which generates new log files each time it is run. They all go to one folder, with filenames like this, and the next log isn't started until the current one is finished.

Log-20140122102407.txt
Log-20140122102739.txt
Log-20140122103640.txt
Log-20140122162121.txt
Log-20140122163145.txt

I want to monitor the current progress in a terminal window like tail -f but that won't work with multiple files. I've heard of multitail, but don't know how to use it, and I don't want my terminal window split into multiple sections.

Best Answer

tail

tail can tail multiple files. Donovan Bray's article explains more, tail: can tail multiple files simultaneously, who knew? and other tail tricks.

To tail multiple files, pass in a file pattern:

tail -f Log-*

multitail

You can ask multitail to combine the output of multiple files. The examples page contains a useful approaches and tricks.

This command combines and tails two logs:

multitail /var/log/apache/access.log -I /var/log/apache/error.log

If you need to tail any logs in a folder, including those actively being created, use the -q flag:

multitail -q 'test*'

This will tail any files matching the pattern test*, including those that appear after the command has been issued. Thanks to @folkert-van-heusden for this suggestion and code fix.

If you have homebrew installed, you can install multitail using the Terminal.app command:

brew install multitail

See also: