Hi,
I am currently working with PayPal's IPN and some of my scripts may have run-time errors or some fatal errors; however, as it is executed by IPN, I have no idea where to debug except by littering log file entries everywhere.
Is there a way to log PHP's error messages to a log file? I know that there is set_error_handler(), but it seems too much to test just one script...
How do I easily log PHP error messages to a log file?
Moderator: General Moderators
-
LonelyProgrammer
- Forum Contributor
- Posts: 108
- Joined: Sun Oct 12, 2003 7:10 am
Re: How do I easily log PHP error messages to a log file?
You can change it in the php.ini or maybe you could try ini_set if allowed by your host?
Code: Select all
ini_set ('track_errors', 1);
ini_set ('log_errors', 1);
ini_set ('error_log', '/logs/.php_errors');
Last edited by lafever on Fri May 02, 2008 3:10 pm, edited 1 time in total.
Re: How do I easily log PHP error messages to a log file?
If you want to make it simpler than the above log, just try:
You can put in an unlink() at the top if you want to clear the log before each execution.
Code: Select all
<?php
function log_error($no,$msg,$file,$line)
{
file_put_contents('error.txt',$msg."\n",FILE_APPEND);
}
set_error_handler('log_error');
?>