2017-10-17 32 views
3

嗨,我沒有訪問php.ini中我用這篇文章How to log errors and warnings into a file?如何編寫只有一個文件中的所有error_logs在PHP

我有23檔和47的public_html子目錄

我想任何地方發生錯誤或警告所有錯誤中寫的public_html/my_error.log

,但現在我有任何子目錄一個error.log中文件

我嘗試的public_html和子這個代碼,但是這只是改變名稱的日誌文件erors目錄

<IfModule mod_php5.c> 
php_flag log_errors on 
php_value error_log ./path_to_MY_PHP_ERRORS.log 
</IfModule> 

感謝

回答

0

我無法訪問爲php.ini

error_log ini directive is writable from everywhere,所以你不需要訪問ini文件本身。您可以用ini_set來設置它,例如

ini_set("error_log", "/path/to/your/error.log"); 

,但現在我有任何子目錄一個error.log中文件

如果你在每一個子目錄中的日誌文件,你可能會在[error_log()][1]指定目的地參數一個relative path instead of an absolute path。介意例如:

error_log("You messed up!", 3, "/var/tmp/my-errors.log"); 

同樣地,在httpd配置片段,使用絕對路徑:

php_value error_log /absolute/path_to_MY_PHP_ERRORS.log 
相關問題