Using PaperTrail & Slack For Laravel Logging

Josh Pollock
Jul 21, 2017 · 2 min read

I really like Papertrail — it’s a simple service that gives you a live updating view of your logs. I wrote a post for Torque awhile ago about using it in WordPress. Since we launched Caldera Forms Pro, most of which is built in Laravel, I’ve been meaning to setup Papertrail for logging.

When we launched, I had built a quick Slack webhook integration to send warnings and errors into Slack channel — and therefore my phone. I also have Laravel Log Viewer. Still I missed having real time log viewing.

I did some googling and found some info, but nothing complete. I got it working base on what I found in Matt Stauffer’s excellent Laravel with Forge series and in the docs and thought I’d share how I got it to send everything logged with Laravel’s Monolog instance to Papetrail.

Make It So

Before starting you need to find the URL and port for your Papertrail log destination. You can use this link while logged into find it. I then put that URL and port in the .env variables “PAPERTRAIL_URL” and “PAPERTRAIL_PORT”.

Then I used the register method of my application service provider to add a new “SyslogUdpHandler” handler, which reading the Monolog source tells me is “for logging to a remote syslogd server” which I assume Papertrail is because this works.

That’s About It

Just a quick post I wanted to share. I also setup the Papertrail system logger on the server, so that I get all system logs, but pretty sure that’s more than I need and I’ll remove that.


Originally published at Josh Pollock.

)
Josh Pollock

Written by

PHP and JavaScript developer. Co-founder CalderaWP. WordPress core contributor. Vegan AF.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade