# Nginx not logging errors

**URL:** <https://www.ruby-forum.com/t/nginx-not-logging-errors/159389>\
**Category:** NGINX\
**Created:** [February 4, 2009, 4:37am UTC](https://www.ruby-forum.com/t/nginx-not-logging-errors/159389 "2009-02-04T04:37:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![x3sphere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ecccb3/32.png) [@x3sphere](https://www.ruby-forum.com/u/x3sphere)\
**Post date:** [February 4, 2009, 4:37am UTC](https://www.ruby-forum.com/t/nginx-not-logging-errors/159389/1 "2009-02-04T04:37:49Z")

</div>

For some reason Nginx has stopped logging PHP errors. Access logs still  
work fine, but any PHP errors are no longer logged. Any reason why this  
would happen? Really stumped here… it was working fine a couple days  
ago.

I’m running PHP as php-fpm, btw. Also I’ve tried changing the error\_log  
config dir, but no luck. Also tried restarting nginx + PHP.

---

<div class="post-metadata">

**Author:** ![x3sphere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ecccb3/32.png) [@x3sphere](https://www.ruby-forum.com/u/x3sphere)\
**Post date:** [February 4, 2009, 5:00am UTC](https://www.ruby-forum.com/t/nginx-not-logging-errors/159389/2 "2009-02-04T05:00:12Z")

</div>

check your php.ini settings for php error log location and corresponding  
settings.

---

<div class="post-metadata">

**Author:** ![x3sphere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ecccb3/32.png) [@x3sphere](https://www.ruby-forum.com/u/x3sphere)\
**Post date:** [February 4, 2009, 5:35am UTC](https://www.ruby-forum.com/t/nginx-not-logging-errors/159389/3 "2009-02-04T05:35:52Z")

</div>

Ilan B. wrote:

> check your php.ini settings for php error log location and corresponding  
> settings.

Log\_errors is on and related settings:

log\_errors = On  
error\_log = /var/log/php/php.errors  
ignore\_repeated\_errors = Off  
ignore\_repeated\_source = Off  
log\_errors\_max\_len = 1024

tried setting log\_errors\_max\_len to 0 but still nothing. Here is my  
entire PHP.ini

[http://pastebin.ca/1326877](http://pastebin.ca/1326877)

---

<div class="post-metadata">

**Author:** ![x3sphere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ecccb3/32.png) [@x3sphere](https://www.ruby-forum.com/u/x3sphere)\
**Post date:** [February 4, 2009, 6:31am UTC](https://www.ruby-forum.com/t/nginx-not-logging-errors/159389/4 "2009-02-04T06:31:04Z")

</div>

Ilan B. wrote:

> I don’t see an immediate issue with it, but I just don’t think that  
> Nginx is  
> the problem in terms of php errors. What about permissions on the error  
> directory?

The permissions are correct, I have both the access and error logs in  
the same directory. The access logs are being written to so no problem  
there.

Is there anything I should add to the FastCGI section in nginx.conf?

```
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME 

```

/srv/www/nginx/domain.com/http$fastcgi\_script\_name;  
include fastcgi\_params;  
}

---

<div class="post-metadata">

**Author:** ![x3sphere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ecccb3/32.png) [@x3sphere](https://www.ruby-forum.com/u/x3sphere)\
**Post date:** [February 4, 2009, 6:06am UTC](https://www.ruby-forum.com/t/nginx-not-logging-errors/159389/5 "2009-02-04T06:06:50Z")

</div>

I don’t see an immediate issue with it, but I just don’t think that  
Nginx is  
the problem in terms of php errors. What about permissions on the error  
directory?

---

<div class="post-metadata">

**Author:** ![x3sphere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ecccb3/32.png) [@x3sphere](https://www.ruby-forum.com/u/x3sphere)\
**Post date:** [February 4, 2009, 8:00am UTC](https://www.ruby-forum.com/t/nginx-not-logging-errors/159389/6 "2009-02-04T08:00:47Z")

</div>

X3 Sphere wrote:

> Ilan B. wrote:
> 
> > I don’t see an immediate issue with it, but I just don’t think that  
> > Nginx is  
> > the problem in terms of php errors. What about permissions on the error  
> > directory?
> 
> The permissions are correct, I have both the access and error logs in  
> the same directory. The access logs are being written to so no problem  
> there.
> 
> Is there anything I should add to the FastCGI section in nginx.conf?
> 
> ```
> location ~ \.php$ {
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME 
> 
> ```
> 
> /srv/www/nginx/domain.com/http$fastcgi\_script\_name;  
> include fastcgi\_params;  
> }

A follow-up to this… the permissions were set incorrectly on my  
php.errors file, it now logs fine.

However… all the errors used to show up in the nginx logs (useful as I  
was able to log errors on a per domain basis). I’m not sure why this  
behavior changed.

---

<div class="post-metadata">

**Author:** ![x3sphere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ecccb3/32.png) [@x3sphere](https://www.ruby-forum.com/u/x3sphere)\
**Post date:** [February 4, 2009, 8:25am UTC](https://www.ruby-forum.com/t/nginx-not-logging-errors/159389/7 "2009-02-04T08:25:33Z")

</div>

On Wed, Feb 04, 2009 at 08:00:47AM +0100, X3 Sphere wrote:

> > 
> 
> A follow-up to this… the permissions were set incorrectly on my  
> php.errors file, it now logs fine.
> 
> However… all the errors used to show up in the nginx logs (useful as I  
> was able to log errors on a per domain basis). I’m not sure why this  
> behavior changed.

What type do you mean ? In general nginx simply can not show php errors  
as they are in independent process.

---

<div class="post-metadata">

**Author:** ![x3sphere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ecccb3/32.png) [@x3sphere](https://www.ruby-forum.com/u/x3sphere)\
**Post date:** [February 4, 2009, 4:36pm UTC](https://www.ruby-forum.com/t/nginx-not-logging-errors/159389/8 "2009-02-04T16:36:43Z")

</div>

Igor S. wrote:

> On Wed, Feb 04, 2009 at 08:00:47AM +0100, X3 Sphere wrote:
> 
> > > 
> > 
> > A follow-up to this… the permissions were set incorrectly on my  
> > php.errors file, it now logs fine.
> > 
> > However… all the errors used to show up in the nginx logs (useful as I  
> > was able to log errors on a per domain basis). I’m not sure why this  
> > behavior changed.
> 
> What type do you mean ? In general nginx simply can not show php errors  
> as they are in independent process.

Errors were showing up in the nginx logs, like this:

2009/02/01 09:49:22 [error] 22004#0: \*466 FastCGI sent in stderr: "PHP  
Notice: Undefined variable: template in  
/srv/www/nginx/domain.com/daos/system/index.php on line 45

Also, general http errors are not being written either. Before, if I  
tried to access a directory that did not exist, it would show in the  
error log. But it no long does this.

2009/02/01 11:13:35 [error] 22004#0: \*13333 open()  
“/srv/www/nginx/domain.com/http/forums/test” failed (2: No such file or  
directory), client: 70.176.235.197, server: [forums.domain.com](http://forums.domain.com), request:  
“GET /test HTTP/1.1”, host: “[forums.domain.com](http://forums.domain.com)”

I’m having a hard time figuring out why it stopped as I haven’t changed  
the config since then, aside from adding a couple more vhosts.

---

<div class="post-metadata">

**Author:** ![x3sphere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ecccb3/32.png) [@x3sphere](https://www.ruby-forum.com/u/x3sphere)\
**Post date:** [February 4, 2009, 9:05pm UTC](https://www.ruby-forum.com/t/nginx-not-logging-errors/159389/9 "2009-02-04T21:05:06Z")

</div>

On Wed, Feb 04, 2009 at 06:32:53PM +0100, X3 Sphere wrote:

> After a lot of testing I have fixed this. The problem was that I did not  
> specify the error value after the path name.
> 
> error\_log /logs/nginx/domain.com/domain\_error.log error;
> 
> However, it was working fine before this without “error” being  
> specified. Doesn’t matter though, I’m just glad I finally found the  
> problem.

What version do you use ?

There was bug (fixed in 0.7.31-0.7.32) when error\_log without logging  
level defined in http/server/location blocks did not log at all.

---

<div class="post-metadata">

**Author:** ![x3sphere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ecccb3/32.png) [@x3sphere](https://www.ruby-forum.com/u/x3sphere)\
**Post date:** [February 4, 2009, 6:32pm UTC](https://www.ruby-forum.com/t/nginx-not-logging-errors/159389/10 "2009-02-04T18:32:53Z")

</div>

After a lot of testing I have fixed this. The problem was that I did not  
specify the error value after the path name.

error\_log /logs/nginx/domain.com/domain\_error.log error;

However, it was working fine before this without “error” being  
specified. Doesn’t matter though, I’m just glad I finally found the  
problem.
