20 July, 2016

How to log PHP debugging message?

I am really novice in the field of PHP, but found it is so critical to debug a PHP application.
I just wanted to print some debug statements from PHP code, and uplon GOOGLEing i was end up in 100 lines of custom LOG classes. which has dependency on another 1000 lines of codes.
PHEW!!!

But at last it turned out to be so simple.
write a function global scope

function phplog( $message)
{
       error_log("\n" . $message, 3, "phplog.log");
 }


And then log it through the call...

phplog ("Hello world!!!");


I found this here, do visit for more info on this.

1 comment:

  1. thank you so much .
    exactly what i needed

    error_log("\n" . $message, 3, "phplog.log");

    $message = which you want to print
    phplog.log= name of the folder where $message will print.

    ReplyDelete