[英]php setting an error log
我很難強迫我的應用程序記錄錯誤。 這是文件層次結構:
/opt
+-lampp
+-htdocs
+-project
+-app
| +-config
| | +-errors.php
| +-controllers
| +-log
| | +-error.log
| +-etc...
| +-index.php
+-pub
這是errors.php:
<?php
/*
* This is configuration for error handling
*/
ini_set('safe_mode','off');
//to display errors in browser, set 1
ini_set('display_errors',1);
//to write errors to a log file, set 1
ini_set('log_errors',1);
//set default file to log errors
ini_set('error_log','app/log/error.log');
//error reporting level, set to E_ALL to see all errors and notices
//error_reporting(E_ALL);
error_reporting(E_ERROR|
E_WARNING|
E_CORE_ERROR|
E_CORE_WARNING|
E_COMPILE_ERROR|
E_COMPILE_WARNING|
E_USER_ERROR|
E_USER_WARNING|
E_STRICT|
E_RECOVERABLE_ERROR|
E_DEPRECATED|
E_USER_DEPRECATED);
error_log('hi');
我在某些文章中讀到,這可能是由安全模式引起的,所以我拒絕了它,但是它什么也沒有改變。
還有一個想法,我的路徑可能是錯誤的,在這種情況下,應該是什么?
我意識到以前曾問過這個問題,但我已經閱讀了這些文章,但它們並沒有幫助我。 即使這是一個“調試我的代碼”問題,有人可以幫助我嗎?
(ps確認error.php文件已到達並執行。)(pps error.php包含在index.php中)
編輯:
所以我評論了安全模式行並轉儲了這些行:
error_reporting => int(22527)
error_log => bool(true)
謝謝你的貼子,我從中學到了很多東西。 當我嘗試絕對路徑時,我發現問題出在文件權限上。 我要做的就是
sudo chmod 777 error.log
無論如何,在項目目錄中擁有777權限的文件是一個好主意嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.