PHP Debug Log – Trace Errors


Hits: 3573  

Hello Friends,

I read some where “Quality is not a product.. it is a process 😉 ”

I think process is hard-work we do and product is final result we get.

But how we make our process to get a good product, as a LAMP developer I think track processes “Debug Log” is good sort of tool for monitoring programs.

Trouble shooting is quite simple with Log Files. Log file can be used with analysis tools, it’s possible to get a good idea of where errors are coming from, how often errors return.

Here you can see a simple PHP script to trace PHP programs…

debugLog.php
………………….

function debugLog($log, $text)
{
$log_dir = dirname($log);
if( !file_exists($log_dir) or !is_dir($log_dir) or !is_writable($log_dir) )
return false;

$write_mode = ‘w’;
if( file_exists($log) && is_file($log) && is_writable($log) )
$write_mode = ‘a’;

if( !$handle = fopen($log, $write_mode) )
return false;

if( fwrite($handle, $text. “\n”) == FALSE )
return false;

@fclose($handle);
}

Debugging Tools:

http://xdebug.org/
http://valgrind.org/
http://www.php-debugger.com/dbg/
http://pecl.php.net/package/apd
http://pear.php.net/package/Benchmark/
http://code.google.com/p/webgrind/

We can’t imagine processes without Log File 😉

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch

16 thoughts on “PHP Debug Log – Trace Errors”

  1. Pingback: GVK Bioscience
  2. Pingback: best seedbox
  3. wonderful submit, very informative. I ponder why the other experts of this sector don’t realize
    this. You should proceed your writing. I am confident, you’ve a great readers’
    base already!

  4. I’m not positive the place you are getting your info, but great topic.
    I needs to spend a while studying more or understanding more.
    Thank you for fantastic info I used to be on the lookout for this information for my mission.

  5. Have you ever thought about adding a little bit more than just your articles?
    I mean, what you say is important and all. However just imagine if you added some great visuals or video
    clips to give your posts more, “pop”! Your content is excellent but with pics and videos, this blog could undeniably be one of the
    most beneficial in its field. Terrific blog!

  6. First off I want to say superb blog! I had a quick question in which I’d like to
    ask if you do not mind. I was curious to find out how you center
    yourself and clear your thoughts before writing.
    I have had a tough time clearing my mind in getting my ideas out
    there. I truly do enjoy writing however it
    just seems like the first 10 to 15 minutes are usually lost simply just trying to figure out how to begin. Any recommendations or hints?

    Appreciate it!

  7. I think the admin of this web page is in fact working hard for his website, for the reason that here every data is quality based material.

  8. I simply couldn’t go away your website before suggesting that
    I actually enjoyed the standard information an individual provide to
    your guests? Is gonna be back frequently in order to check up on new posts

  9. When someone writes an article he/she keeps the thought of a user in his/her brain that how a user can be
    aware of it. Thus that’s why this paragraph is amazing.
    Thanks!

  10. Hello there, I do believe your blog might be having
    web browser compatibility problems. Whenever I take a look at your
    site in Safari, it looks fine however, when opening in I.E., it has some overlapping issues.
    I merely wanted to provide you with a quick heads up! Aside
    from that, fantastic blog!

  11. Thank you a lot for sharing this with all of us you really know what you’re speaking approximately!
    Bookmarked. Kindly additionally consult with my web site =).
    We may have a hyperlink exchange contract among us

Leave a Reply

Your email address will not be published.

*