I used to use the following to log specific errors:
<?php
$log = 'rejected';
if (filesize($log) > 20000) unlink($log);
$data = date('d-m-Y H:i:s')." [$fault]\r\n";
error_log($data,3,$log);
?>
But, this meant that sometimes there would only be a few errors shown, if the 
file had reached it's 20000 limit and deleted itself.

So I created a rolling road log of a 100. This allows me to view trends easier. 
I'm not sure how efficient this is, or whether it would be suitable for high 
volume?
<?php
$log = 'rejected';
$data = date('d-m-Y H:i:s')." [$fault]\r\n";
if (file_exists($log))
{
  $records = file($log);
  array_unshift($records,$data);
  if (count($records) > 100) array_pop($records);
  $fp = fopen($log,'w');
  foreach ($records as $item) fwrite($fp,$item);
  fclose($fp);
}
else
{
  $fp = fopen($log,'w');
  fwrite($fp,$data);
  fclose($fp);
}
?>

Has anyone got a better method, or can improve it?
Regards, Bob E.




------------------------------------

Please remember to write your response BELOW the previous text. 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-list/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to