Episode 7: Logging with Papertrail
Logging is important!
In this episode I integrate Laravel with Papertrail and add some colour highlighting.
Logging… it's good for diagnosing issues, tracking the peformance of you app or just tracking key metrics and usage.
I setup Papertrail - an external logging service that can handle and present your logs more effectively than a text file.
Tools and Resources Mentioned
- PapertrailApp.io – Use this link and get an additional 50MB/month for your first year!
- Monolog Coloured Line Formatter – GitHub repository for the Monolog Line Formatter
- ANSI-PHP – GitHub repository for generating control sequences (carriage return, line feed, colors) in PHP
- 0:00:00 – Introduction, episode objectives
- 0:01:10 – Review of existing Laravel Logging
- 0:01:57 – Introduction to Papertrail
- 0:03:03 – Setting up the .env file
- 0:06:50 – Introduction to Monolog
- 0:07:50 – Overview of UDP usage by Papertrail
- 0:10:20 – Changing the Monolog behaviour in Laravel
- 0:14:20 – Enabling sockets extension in PHP
- 0:20:30 – Adding context to error messages
- 0:24:40 – Adding colour to log messages
- 0:29:30 – Customising the colour scheme
- 0:37:30 – Tidying up the code before committing
- 0:42:30 – Review and end