nginx php-fpm how to disable log warnings?
I've a setup with nginx + php-fpm. I found in my nginx error log a lot of PHP Warning messages like this:
2016/03/17 20:57:23 [error] 23002#0: *114868 FastCGI sent in stderr: "PHP message: PHP Warning: Declaration of Walker_Category_Filter::start_el(&$output, $category, $depth, $args) should be compatible with Walker_Category::start_el(&$output, $category, $depth = 0, $args = Array, $id = 0) in /var/www/wp-content/themes/venture/functions/theme/custom-post-types.php on line 0
PHP message: PHP Warning: Parameter 1 to W3_Plugin_TotalCache::ob_callback() expected to be a reference, value given in /var/www/wp-includes/functions.php on line 3464", client: 52.69.241.233, server: www.myhost.net, request: "GET /appuntamenti/ HTTP/1.1", host: "www.myhost.net"
I don't want to log event like this, they fill up my logs and create a lot of rumors on New Relic reports. Do you knwow ho to change this behavior of nginx?
I've tried to change my php.ini configuration with this:
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
The event are logged in nginx error log, so I think that's not related to php-fpm configuration.
Any suggestion is welcome
Thanks Fabio
Those are warnings generated by PHP itself; since they're printed to stdout (or maybe stderr) without being caught, they end up in your server logs.
I would expect that entry in your php.ini
to be sufficient to silence those warnings. If that is not happening, you should check to see if the application overrides those settings through the error_reporting()
function.
In general, you should pay attention to warnings - they are warnings after all! Whoever is responsible for maintaining the application (that might be you) should look into them and fix them; silencing them in your logs is just papering over the issues, and may come back to bite you in the ass.
Although Xiong's answer worked for you, I had to use the following method.
After editing PHP.ini files and ensuring no ini_set/error_reporting values and restarting php5-fpm service I was still getting Warnings appeared in the end I had to add this to my fpm pool file
/etc/php5/fpm/pool.d/www.conf
to turn off warnings:
php_admin_value[error_reporting] = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED
then restart service
service php5-fpm restart
nginx add
location / {
...
fastcgi_param PHP_ADMIN_VALUE "error_reporting=E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED";
...
}