Jump to content

PHP log of output


stevire

Recommended Posts

Hey guys,

 

I'm using php with postgreSQL and apache. I have php functions that produce sql statements and run them against the database. Is there anyway to log these sql statements with all the user inputted values?

 

I had this going before, but can't remember how I did it!!  :-[

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/145417-php-log-of-output/
Share on other sites

want to write it to a file, send an email somewhere, or store it in a table?

If you want to write it to a file (which makes more since), use something like

function logstatement($sql){
$file = "logs/log.log";
$handle = fopen($file, 'a');
fwrite($handle, "\n".$sql, filesize($file)+1000);
fclose($handle);
}

Edit: I added \n onto the write so that the logs would be on their own lines. BTW, there is legal problems with doing this in some situations which mostly stem from what you plan on doing with the data. If it is for trouble shooting or for quality improvement/assurance than you are okay. I'll assume that that is what you plan on using it for...

Link to comment
https://forums.phpfreaks.com/topic/145417-php-log-of-output/#findComment-763383
Share on other sites

The php.ini logging settings apply to php generated errors. For your application to "automatically" do anything, you must write code to cause it to happen.

 

Also see the error_log function on how you can log information in your application program.

Link to comment
https://forums.phpfreaks.com/topic/145417-php-log-of-output/#findComment-763415
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.