Pail — A Laravel Package for Tailing Logs
A few days ago I discussed many ways to tail logs in Laravel. And it hasn’t been long since I wrote that article, a new package called Pail has popped up on my radar which is also a Laravel package for tailing logs.
The package was built by Nuno Maduro. It’s a pretty simple package that lets you tail logs in your Laravel application using the
artisan pail command. It’s a zero-configuration package which means you don’t have to do anything to get it working. It just works out of the box.
The only prerequisite for this package is that your project should be running on PHP 8.2 or higher. Also, keep in mind that the package is still in the development phase. So, it’s not recommended to use it in production yet.
You can install the package using the composer like so.
composer require laravel/pail:1.x-dev
Note: If you face any issues while installing the package, run
composer updateand then try again.
Once installed, you can start tailing logs using the following command.
php artisan pail
This will start tailing the logs in your terminal like so.
As you can tell, the package shows the log in a pretty sleek-looking way so that it’s easy to distinguish between different log levels. All the logs are color-coded and the error logs are printed on the next line so that it’s easy to spot them.
On top of that, the package also shows contextual information like the authenticated user, the request URL, and the request method.
You can filter the logs by specifying the
--filter option like so.
php artisan pail --filter="error"
The package also provides the feasibility of filtering logs based on an authenticated user. You can do so by specifying the
--user option like so.
php artisan pail --user=1
This will only show the logs that are related to the user with the ID
Check out the package’s repository → Pail
Like this article? Consider leaving aTip