Forum Moderators: coopster

Message Too Old, No Replies

Appending to logged PHP error messages

         

thing3b

10:47 pm on Oct 8, 2006 (gmt 0)

10+ Year Member



I log all error messages to a log file with the following code:

// Error logging
ini_set( 'log_errors', 1 );
ini_set( 'display_errors', 0 );
ini_set( 'error_log', LOG_DIR . '/Log - PHP Errors.txt' );
ini_set('ignore_repeated_errors',0);

The problem with this is that the same PHP script is used for more than one site and it is hard to track does the source of the errors. Can anyone suggest a method of appending a string to each logged message so that extra information can be included into the log entry?

I am aware that I could use the following code to split it into a log file per site:


ini_set('error_log', LOG_DIR.'/'.$_SERVER['HTTP_HOST'].'/Log - PHP Errors.txt' );

but I would like to also append extra information such as the Referer, IP and some other variables to the message that will help me recreate the error conditions.

eelixduppy

12:31 am on Oct 9, 2006 (gmt 0)



The set_error_handler [us3.php.net] function is what you're looking for.