Re: Log PHP Error Messages
Posted: Sat Dec 25, 2010 3:36 am
Setup custom error handler and log the IP - http://php.net/set_error_handler
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
It's not hard:Waterburn wrote:Darhazer, thanks for your reply. But setting up a custom error handle is a bit too much for me as a beginner. Is is possible to do this an easier way?
Code: Select all
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting
return false;
}
$filename = 'errors.log';
$msg = '['.$_SERVER['REMOTE_ADDR'].']';
$msg .= $errstr ' at ' . $errfile.':'$errline;
file_put_contents($filename, $msg, FILE_APPEND);
return true;
}
set_error_handler('myErrorHandler');