エラーをエラー ログ ファイルに書き込み、エラーの一部を画面に出力する単純な PHP スクリプトがあります。
Aptana Studio 内の「サンドボックス」プロジェクトで最初に開発しました (ただし、実際には単なるディレクトリです)。そこでは、見事に機能しました。ただし、それを「本番プロジェクト」にコピーすると (これも、実際には Web サーバー上の別のディレクトリにすぎません)、errorlog.log
ファイルにメッセージが記録されなくなりました。すべての権限は同じです。実際、スクリプトを実行可能にし (他のディレクトリにはありませんでした)、ディレクトリに完全な権限を与えました (chmod 777)。errorlog.log
ファイルは既に空のファイルとして存在し、サンドボックスにあった場合と同様に書き込み可能です。
コードは次のとおりです。
<?php
/* logerrors.inc.php - Prints a "formatted" error message which will be displayed
* within a handler (i.e. the notification bar) on the front end and writes
* the error to a text log.
*/
date_default_timezone_set('America/New_York'); // Required to avoid errors.
define("LOG_LOCATION", "errorlog.log"); // The location of the log file
function writeError($error_string, $technical_info_string = ""){
$tech_log_entry = ""; // We should only log techinical information
// if it's provided
if($technical_info_string != ""){
$tech_log_entry = "\n- Technical Info Provided: ". $technical_info_string;
}
// Writes a log entry with full details.
error_log("[ERROR: ".date('Y-m-d H:i:s') . "]\n- Error Displayed: ". $error_string .
$tech_log_entry ."\n\n",
3, LOG_LOCATION);
echo "error: " . $error_string; // Emits the $error_string as output
exit();
}
?>
興味深いことに、echo
スクリプトの下部にあるコマンドは問題なく機能しているため、関数でエラーが発生していないことは明らかerror_log
です。それは機能していません。
次にどこを見るべきか、またはこれを引き起こしている可能性があるものについて何か考えはありますか?