有沒有辦法顯示來自PHP的錯誤,但在日誌文件中禁用它們?在屏幕上顯示錯誤,但禁用文件記錄
目前,我有這樣的:
// Log all errors
error_reporting(-1);
// Display none
ini_set('display_errors', 0);
什麼是周圍的其他方式?
有沒有辦法顯示來自PHP的錯誤,但在日誌文件中禁用它們?在屏幕上顯示錯誤,但禁用文件記錄
目前,我有這樣的:
// Log all errors
error_reporting(-1);
// Display none
ini_set('display_errors', 0);
什麼是周圍的其他方式?
在你php.ini
文件,停止錯誤被報告到日誌文件中轉入log_errors = Off
; Besides displaying errors, PHP can also log errors to locations such as a
; server-specific log, STDERR, or a location specified by the error_log
; directive found below. While errors should not be displayed on productions
; servers they should still be monitored and logging is a great way to do that.
; Default Value: Off
; Development Value: On
; Production Value: On
; http://php.net/log-errors
log_errors = Off
同時確保display_errors
是
; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; For production environments, we recommend logging errors rather than
; sending them to STDOUT.
; Possible Values:
; Off = Do not display any errors
; stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
; On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = On
編輯文件 - /etc/httpd/conf/httpd.conf中
從這個:
CustomLog logs/access_log common
ErrorLog logs/error_log
這樣:
#CustomLog logs/access_log common
#ErrorLog logs/error_log
這將禁用所有的錯誤,無論PHP或Apache除了你也抑制你的訪問日誌:( –
不錯的了;)這是正是我一直在尋找。謝謝!好的部分是兩者都可以使用'ini_set()'函數進行配置 – CIRCLE