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:

http://mailman.nginx.org/pipermail/nginx/2009-February/009567.html (tried putting error as error_log pram – no luck)

http://forum.nginx.org/read.php?2,58447,58447 (dont have stale process after stopping nginx)

Here is the virtual host info:

server {
        server_name .qa.domain.ca;
        root /var/www/qa.domain.ca;
        access_log /var/log/nginx/qa.domain.ca/access.log;
        error_log /var/log/nginx/qa.domain.ca/error.log;
        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_pass   127.0.0.1:9000;
                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 answer on Server Fault.

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