Error Log parms

Since not all of us can get access to the server logs, how's about coding the error_log() calls using variables defined at the to of the script, so that users can set up logging to a file if required?

Regards
Paul

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Error Log parms

Hmm, I'll take a look into it. The only thing that I'm not sure about trapping would be PHP errors themselves. Either way it's worth checking out.

-Andrew Riley

Error Log parms

Changing the way that locally defined log entries are reported has no bearing on error logs for PHP errors does it? Or am I missing something.

Here are the changes that I made:

// Define log stuff as an array to make it easier to add to "global" entries

$error_log_array = array(
'log_header'=>"[PHPFormMail]\t" . getenv('REMOTE_ADDR') . "\t" . getenv('HTTP_REFERER') . "\t" . date('Y-m-d H:i:s (T)') . "\t",
'log_option'=>3,
'log_destination'=>'mel/article.log',
'log_extras'=>'',
'log_newline'=>"\r\n",
'log_tab'=>"\t");

Each log line now looks like this:

error_log( $error_log_array['log_header'] . '>Illegal Referer>' . $error_log_array['log_newline'] , $error_log_array['log_option'], $error_log_array['log_destination'], $error_log_array['log_extras']);

Common headers mean that all log entries for a particular transaction can be grouped.

User login