One of the most basic tasks of web development (or any other system development) is to log each and every event maybe that is error logs or any events. This will be beneficial for monitoring applications. For this we have an online service to logs events known as Papertrail. The logging support over a large platform but here we will only show a demo coding setup for logging laravel logs in a precise way. What is more exciting is that the service offers a real-time logging mechanism which is very fruitful for gathering logs in no time. This gives you a live updating view of your logs.
Just signup/login to the service and get the URL and PORT which will be unique to your account. You will find the URL and port for your Papertrail log destination while logged in to find it. Just put that URL and port in the .env variables PAPERTRAIL_URL and PAPERTRAIL_PORT.
On Laravel version over 6.x there is out of box method of integration of this service which is very easy and precise. Just two lines of values are enough to set up the papertrail app. You can also refer to the laravel official logging docs for this. On the logging config just enable the paper trail logging driver whether on the stack or individually.
on the .env file
‘papertrail’ => [ ‘driver’ => ‘monolog’, ‘level’ => ‘error’, ‘handler’ => SyslogUdpHandler::class, ‘handler_with’ => [ ‘host’ => env(‘PAPERTRAIL_URL’), ‘port’ => env(‘PAPERTRAIL_PORT’) ] ]
Finally when there are some logging events it will automatically see in the events of papertrail dashboard. You can also follow the papertrail integration link for PHP as well as it supports many other platforms easily.
It uses a socket to send the event to papertrail app so make sure your system has socket extensions. On PHP, just open the socket extension on your corresponding web server
You can check the pricing which also gives a basic free version with no credit card required.