Reputation: 28187
I understand a 500 response can be returned under a variety of different scenarios, but is there any way to have the server log specifically what caused the 500? Or for that matter print it to the PHP page/output?
EDIT:
I'm on MediaTemple's Grid Service, display errors is on in phpinfo()
, the following is in my PHP code: ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
and error logging is turned on in my hosting configuration, yet when I tail
the log, nothing appears when I hit refresh. Any ideas?
Upvotes: 1
Views: 340
Reputation: 41965
You can try :
$log_file = 'c:temp\test_error.txt';
register_shutdown_function('handleShutdown');
function handleShutdown() {
global $log_file;
$error = error_get_last();
if ($error !== NULL) {
$info = "[SHUTDOWN] file:" . $error['file'] . " | ln:" . $error['line'] . " | msg:" . $error['message'] . PHP_EOL;
file_put_contents($log_file, $info, FILE_APPEND);
} else {
file_put_contents($log_file, "SHUTDOWN ", FILE_APPEND);
}
}
Upvotes: 0
Reputation: 270757
The cause of the 500 error should be in Apache's error log already. If PHP was responsible, then the error will be shown on screen if you have display_errors = On
in php.ini.
Upvotes: 1