How to stop certain warning logging in error.log?

“Technically” it’s just a PHP warning and not an error, and you should not have warnings enabled on production servers. You can disable PHP from logging warnings and it will still log errors to the error log file.

You can disable PHP warnings by setting it in a custom php.ini file on the server (all errors except for warnings):
error_reporting = E_ALL & ~E_WARNING

or try setting it with PHP:

error_reporting(E_ALL & ~E_WARNING);

From php.ini file:

; Common Values:
;   E_ALL (Show all errors, warnings and notices including coding standards.)
;   E_ALL & ~E_NOTICE  (Show all errors, except for notices)
;   E_ALL & ~E_NOTICE & ~E_STRICT  (Show all errors, except for notices and coding standards warnings.)
;   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; http://php.net/error-reporting

Leave a Comment