7

I have a pretty common problem I think, but I can't find any "best practice" answer to it.

I developped a lot of small web apps based on a home made framework for my clients. Those apps are used only in a very specific business related context, they are used for something like a mounth in a year by an average of ten users.

Each app has a very diffrent purpose and "technology" behind it (sometimes it's Zend modules, TCPDF, etc...). Of course, once in a while users find some minor bugs (not handled exceptions, not set arrays ...).

The problem is, that users won't communicate about it for days or weeks, so when I have to debug, sometimes I don't have all the information I need (like, how to reproduce it, which route it was, etc ...).

For my home made framework (very Laravel-like) I made some functions that handles those errors (using set_error_handler, register_shutdown_function, ...). Basicly those function will create some log entry in client's MySQL database.

I use those functions for two purposes :

  1. Log user actions AND php errors + context (routes, controllers, some data flow, php predefined variables, ...)
  2. Warn me when something goes wrong (by mail, SMS, etc ...)

The only way I can analyse all these logs efficiently is when they are in a database (i have a JQuery table rendring them optimized for faster reading and tracking). Otherwise, i would just use text files, but I can't analyse them so fast (too much information).

Question

I just started a project with Laravel (which I'll be using for all my projects now), after some documentation reading I've found that Laravel uses Monolog for logs. BUT, Monolog don't have a PDO handler, some people may say that using MySQL for logs is a very bad idea (Can Laravel 4 log to a MySQL database?) and I totally agree with them. But it is the only way i've found to do efficient bug correction when working with a lot of small projects with a limited time to dedicate to it.

Note : My clients only have MySQL, I don't have the time to use unit testing (small company, no money for that).

Is there a better solution for my problem (log users activities AND php errors in a structured way, mail/SMS notification when errors are catched) using some Laravel magic I don't know about yet ?

Community
  • 1
  • 1
Hrusdik
  • 225
  • 3
  • 8
  • 1
    Looking through the [Monolog handlers](https://github.com/Seldaek/monolog/tree/master/src/Monolog/Handler) they appear to be quite simple. You just have to extend the abstract `AbstractProcessingHandler` class and implement the `write()` method. Look at the other handlers to see how they do it, and then implement the PDO version yourself (it looks like it should be easy enough). – Sverri M. Olsen Sep 18 '14 at 10:46
  • Sure, that's not a problem, but I am looking for a better solution (maybe using *.ini files instead of MySQL or binary files). Because MySQL gets 10000 inserts per day just for logs (with 10 users). It's a small app, ok, but that's some heavy logging ... – Hrusdik Sep 18 '14 at 10:52
  • 1
    I had the same problem, that's why I developed Laravel Stats Tracker: https://github.com/antonioribeiro/tracker – Antonio Carlos Ribeiro Sep 18 '14 at 15:20

1 Answers1

6

Sure, there are number of tools that can monitor your log files for you and then collate them into meaningful information. They can group similar errors and provide you with detailed data on the kinds of requests that cause them. Better yet, you can elect to pass user data along with errors so you can see exactly what is causing issues.

Here are some that I've come across in my time

Dwight
  • 12,120
  • 6
  • 51
  • 64