Page 1 of 1

Log error and other information

Posted: Tue Mar 15, 2011 6:01 pm
by rasspass
I need to know what is going in different stages of execution process. I am thinking to echo/print statements in in many different PHP files and write them into some text file. Is there a log file that I can customize it for my needs or is there a way to write to a text file? Please note that I have multiple PHP/HTML files that I need to trace and print message/status to a text file. Your suggestion is appreciated in advance.

Re: Log error and other information

Posted: Thu Mar 17, 2011 7:00 pm
by danwguy
I would create a function in a seperate php file to write to a text file and take input kinda of like this...

Code: Select all

function logerror($input)
{
$myFile = "errorfile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $input \n;
fwrite($fh, $stringData);
fclose($fh);
}
then you can call that function with whatever you want to input into it like this...

Code: Select all

$error1 = logerror(put your text here that you want to be input to that text file);
and viola you have a text file on your server that contains whatever you want to put into it.

Re: Log error and other information

Posted: Thu Mar 17, 2011 7:54 pm
by Weirdan