reedmaniac.com
– the blog –

Laravel Logging - Customization

It has been bothering me for a while that Laravel's default logging sort of tossed everything together into one file. I use Info and Debugging messages quite frequently in my work just to keep track of what is happening on the backend, specifically whenever a queue is used. For example, when you hit a Third Party API to retrieve more data for an entity, it is nice to know what the data payload was and if it was successful. Another important use case is throttling. If you have some script kiddie from England hitting your login routine on a regular basis (actually happened), that is a piece of information that it would be nice to know.

Further, error messages are pretty darn critical. If a piece of code is failing on your API or an incorrect validation rule is being sent, it is rare that users will actually send you an email about it. Most just close the browser and move on. Logging is très important.

Since I am getting close to finishing v3 of Bookbranch and there is quite a bit more functionality being added, I thought it was time to sit down and resolve this particular grievance. Below is the code I added to the top of app.php to separate out my three logs into separate files and now on production if an error happens, an email is sent to me so I can quickly address it.