Laravel Tail can now tail remote logs original

by Freek Van der Herten – 2 minute read

laravel-tail is one of my favourite packages. When installed in a Laravel app it can be used to tail the log file.

To tail a log file locally, you just have to issue this command:

php artisan tail

and it'll start tailing the latest log file (so it works for both daily and single log files). Any line written to the log gets displayed immediately on your console.

Recently, we released v4 of the package. A major new addition is that the package can now also tail remote logs. To tail a remote log, you just have to add a couple of lines to your .env file.

Here's an example for freek.dev:

TAIL_HOST_PRODUCTION=freek.dev
TAIL_USER_PRODUCTION=forge
TAIL_LOG_DIRECTORY_PRODUCTION=/home/forge/freek.dev/current/storage/logs

With that in place the remote logs can be tailed with:

php artisan tail production

You can use the --lines option to also view the last X lines already present in the log.

tail

Behind the scenes this feature is powered by the SSH package we released last week.

To know more about the spatie/laravel-tail package, head over to the readme on GitHub.

Join 9,500+ smart developers

Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."

Bert De Swaef — Developer at Vulpo & Youtuber at Code with Burt

No spam. Unsubscribe anytime. You can also follow me on X.

Found something interesting to share? Submit a link to the community section.