Nginx error log is not working

Jay asked:

I have tried many things but not being able to make error log work, however access log is working fine.

solution mentioned here didn’t work for me: (tried putting error as error_log pram – no luck),58447,58447 (dont have stale process after stopping nginx)

Here is the virtual host info:

server {
        root /var/www/;
        access_log /var/log/nginx/;
        error_log /var/log/nginx/;
        index index.html index.htm index.php;

        # redirect to non-www
        if ($host ~* ^www\.(.*)){
                set $host_without_www $1;
                rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;

    if (-d $request_filename){
                rewrite ^/(.*[^/])$ /$1/ permanent;
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
                try_files $uri $uri/ /index.php;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        location ~ .php$ {
                if (!-f $request_filename) {
                        return 404;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
                include fastcgi_params;

My answer:

Aside from upgrading PHP to the latest version, which should have the fix for the bug you’re experiencing, you can also have PHP generate its own error logs. For instance, I have a system where PHP logs to syslog. You can control this with the error_log directive in php.ini.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.