有没有一种方法可以显示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