# 404s logged in error.log?

**URL:** <https://www.ruby-forum.com/t/404s-logged-in-error-log/234912>\
**Category:** NGINX\
**Created:** [May 18, 2013, 3:41am UTC](https://www.ruby-forum.com/t/404s-logged-in-error-log/234912 "2013-05-18T03:41:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [May 18, 2013, 3:41am UTC](https://www.ruby-forum.com/t/404s-logged-in-error-log/234912/1 "2013-05-18T03:41:47Z")

</div>

I was wondering if someone could confirm that requests resulting in a  
404  
response are by default logged to error.log at error level “error”.

Is that normal, or is there some piece of configuration I am missing  
that  
will stop them from being logged to error.log? I figured 404s would be  
an  
un-exceptional event that doesn’t require error logging, but perhaps I’m  
simply not handling that situation correctly in my configuration. Worth  
double-checking.

Thank you!

Posted at Nginx Forum:

> **[404s logged in error.log?](https://forum.nginx.org/read.php?2,239307,239307#msg-239307)**
>
> I was wondering if someone could confirm that requests resulting in a 404 response are by default logged to error.log at error level "error". Is that normal, or is there some piece of configuration I am missing that will stop them from...

---

<div class="post-metadata">

**Author:** ![akurilin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b19c9b/32.png) [@akurilin](https://www.ruby-forum.com/u/akurilin)\
**Post date:** [May 18, 2013, 4:06am UTC](https://www.ruby-forum.com/t/404s-logged-in-error-log/234912/2 "2013-05-18T04:06:55Z")

</div>

----- Original Message -----

> I was wondering if someone could confirm that requests resulting in a  
> 404  
> response are by default logged to error.log at error level “error”.
> 
> Is that normal, or is there some piece of configuration I am missing  
> that  
> will stop them from being logged to error.log? I figured 404s would be  
> an  
> un-exceptional event that doesn’t require error logging,

Correct.

> but perhaps  
> I’m  
> simply not handling that situation correctly in my configuration.  
> Worth  
> double-checking.

4xx responses are a client errors and don’t go in the error.log

5xx are server errors which do go in the error log.

---

<div class="post-metadata">

**Author:** ![akurilin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b19c9b/32.png) [@akurilin](https://www.ruby-forum.com/u/akurilin)\
**Post date:** [May 18, 2013, 4:11am UTC](https://www.ruby-forum.com/t/404s-logged-in-error-log/234912/3 "2013-05-18T04:11:01Z")

</div>

Hey,

> Is that normal, or is there some piece of configuration I am missing that  
> will stop them from being logged to error.log? I figured 404s would be an  
> un-exceptional event that doesn’t require error logging, but perhaps I’m  
> simply not handling that situation correctly in my configuration. Worth  
> double-checking.

The default behavior is to log such events.

You can change it with the “log\_not\_found” directive:

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#log_not_found)**
>
> This directive appeared in version 1.11.8.

Best regards,  
Piotr S.

---

<div class="post-metadata">

**Author:** ![akurilin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b19c9b/32.png) [@akurilin](https://www.ruby-forum.com/u/akurilin)\
**Post date:** [May 18, 2013, 4:47am UTC](https://www.ruby-forum.com/t/404s-logged-in-error-log/234912/4 "2013-05-18T04:47:49Z")

</div>

I might have misread the two answers here, but I get the impression that  
they’re saying the exact opposite of each other. Here’s a sample  
(redacted)  
error message I’m seeing in error.log when doing a GET on a file that  
doesn’t exist:

2013/05/18 02:21:27 [error] 11619#0: \*417 open()  
“/var/www/mysite/foo.html”  
failed (2: No such file or directory), client: 123.123.123.123, server:  
[my.server.com](http://my.server.com), request: “GET /foo.html HTTP/1.1”, host: “[my.server.com](http://my.server.com)”

Just to confirm, should I be seeing the error message above in  
error.log, or  
did I misconfigure something? I can see a corresponding 404 being logged  
in  
access.log.

Thanks again.

Posted at Nginx Forum:

> **[Re: 404s logged in error.log?](https://forum.nginx.org/read.php?2,239307,239310#msg-239310)**
>
> I was wondering if someone could confirm that requests resulting in a 404 response are by default logged to error.log at error level "error". Is that normal, or is there some piece of configuration I am missing that will stop them from...

---

<div class="post-metadata">

**Author:** ![akurilin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b19c9b/32.png) [@akurilin](https://www.ruby-forum.com/u/akurilin)\
**Post date:** [May 18, 2013, 5:51am UTC](https://www.ruby-forum.com/t/404s-logged-in-error-log/234912/5 "2013-05-18T05:51:30Z")

</div>

Perfect, that clarified it, thank you. I will turn off log\_not\_found and  
stick to having 404s just in my access logs, to be on the safe side.

Posted at Nginx Forum:

> **[Re: 404s logged in error.log?](https://forum.nginx.org/read.php?2,239307,239312#msg-239312)**
>
> I was wondering if someone could confirm that requests resulting in a 404 response are by default logged to error.log at error level "error". Is that normal, or is there some piece of configuration I am missing that will stop them from...

---

<div class="post-metadata">

**Author:** ![akurilin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b19c9b/32.png) [@akurilin](https://www.ruby-forum.com/u/akurilin)\
**Post date:** [May 18, 2013, 5:24am UTC](https://www.ruby-forum.com/t/404s-logged-in-error-log/234912/6 "2013-05-18T05:24:03Z")

</div>

----- Original Message -----

> I might have misread the two answers here, but I get the impression  
> that  
> they’re saying the exact opposite of each other.

If you analysed the responses and what you have I suspect you would of  
realised that I was in error and the information you have and the  
directive highlighted by Piotr gives you the ability to manipulate the  
logging to what you want.

> “[my.server.com](http://my.server.com)”
> 
> Just to confirm, should I be seeing the error message above in  
> error.log, or did I misconfigure something? I can see a corresponding 404 being  
> logged in access.log.

A misconfigure assessment depends on what you want. The logs highlight  
that 404 do appear in the error log though this doesn’t need to be the  
case (  
[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#log_not_found) )
