簡體   English   中英

在CentOS 7.3和PHP7中我無法得到php錯誤來登錄到自定義日志

[英]I can't get php errors to log to a custom log in CentOS 7.3 and PHP7

我在public_html的php.ini中有

display_errors = on

error_reporting = E_ALL | E_STRICT

log_errors on
error_log  /home/account/public_html/error.log

phpinfo顯示public_html中的php.ini文件正在加載。 error_log文件具有755權限,並且與public_html所有其他文件屬於同一group:owner。

但是,當我強制執行php錯誤時,不會顯示或記錄任何錯誤。 錯誤記錄在/usr/local/apache/logs/error_log 我已經重新啟動了Apache。

有任何想法嗎?

嘗試更改:

log_errors on
error_log  /home/account/public_html/error.log

log_errors = on
error_log = /home/account/public_html/error.log

接下來,在腳本頂部附近,執行以下操作:

echo php_ini_loaded_file(); // to make sure that you're editing the right php.ini
echo ini_get('log_errors'); // should be '1'
echo ini_get('error_log');  // should be path from php.ini

如果設置與您設置的設置不匹配(我假設您已重新啟動Apache),請檢查php.ini的其余部分以及Apache VirtualHost配置,以獲取可能會覆蓋您的其他設置。

當您運行phpInfo() ,它有時會顯示要加載的ini文件的列表(不僅僅是基本的php.ini 。其中一個還可以包含替代項。

最后,如果這些都不起作用,則可以使用ini_set()設置腳本錯誤記錄。 請注意,如果該腳本本身有錯誤,則此設置可能沒有機會生效,因此最好在與主腳本分開的腳本中進行設置並要求它

main.php

require_once('./init.php);
// ... your regular script

init.php

ini_set('log_errors', '1');
ini_set('error_log', '/path/to/errors.log');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM