The Developer Day | Staying Curious

Oct/07

12

PHP Fatal Errors Handling Continued

In my previous post I wrote about few ideas how to capture PHP fatal errors. After some more research I found a few more elegant solutions.

You can wrap all your site with ob_start which accepts a call back function as a parameter which it calls when the content is flushed to the browser. You can use that call back function to preg match for fatal errors.

Another solution is the one I like the most. In my previous post I wrote about a possibility to examine the PHP errors log. Well I found that there are log watch tools to do that easily.

With something like this:

watchfor /(PHP.*error:.*?)$/i
mail addresses=root
threshold=on
threshold track_by=$1,type=limit,count=1,seconds=10

# swatch -daemon -c /root/php_fatal.conf -tail-file=/var/log/apache2/error.log

You can easily track php errors and send them to yourself over the email. And the most exciting detail about this tool is that it won’t spam you with thousands of emails with the same error.

RSS Feed

No comments yet.

Leave a comment!

<<

>>

Find it!

Theme Design by devolux.org