..
Moderator: General Moderators
Re: Log PHP Error Messages
Setup custom error handler and log the IP - http://php.net/set_error_handler
-
jarofgreen
- Forum Commoner
- Posts: 71
- Joined: Sun Jul 11, 2010 12:40 pm
Re: Log PHP Error Messages
Sorry if this is a bit more complex than you want, but I'm working on a ticket system which has a module that collects full error reports including IP and environmental variables.
http://sourceforge.net/news/?group_id=317819&id=293422
The project is http://elastik.sourceforge.net/
http://sourceforge.net/news/?group_id=317819&id=293422
The project is http://elastik.sourceforge.net/
Re: Log PHP Error Messages
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');