# Nginx not logging access

**URL:** <https://www.ruby-forum.com/t/nginx-not-logging-access/213280>\
**Category:** NGINX\
**Created:** [October 28, 2011, 6:34pm UTC](https://www.ruby-forum.com/t/nginx-not-logging-access/213280 "2011-10-28T18:34:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [October 28, 2011, 6:34pm UTC](https://www.ruby-forum.com/t/nginx-not-logging-access/213280/1 "2011-10-28T18:34:39Z")

</div>

It does seem to be logging some access (on my local network and then  
looping back in from my router’s IP), but I’m not seeing access from  
someone external to my house. I can see that a connection exists in  
netstat, I can see my transmitted bytes incrementing when I look at  
eth0, but nginx has failed to log this to the access.log. Obfuscations  
were made to protect the innocent.

Here is netstat:

tcp 0 197100 home-srv.local:8000 ip1-2-3-5.aj.:52927  
ESTABLISHED

Here you can see eth0 tx incrementing (pulled within a second of each  
other):

root@home-srv:/var/log# ifconfig eth0  
eth0 Link encap:Ethernet HWaddr 48:5b:39:86:b0:09  
inet addr:192.168.1.10 Bcast:192.168.1.255  
Mask:255.255.255.0  
inet6 addr: fe80::4a5b:39ff:fe86:b009/64 Scope:Link  
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1  
RX packets:367829 errors:0 dropped:0 overruns:0 frame:0  
TX packets:481053 errors:0 dropped:0 overruns:0 carrier:0  
collisions:0 txqueuelen:1000  
RX bytes:26445268 (26.4 MB) TX bytes:707235638 (707.2 MB)  
Interrupt:41 Base address:0x6000

root@home-srv:/var/log# ifconfig eth0  
eth0 Link encap:Ethernet HWaddr 48:5b:39:86:b0:09  
inet addr:192.168.1.10 Bcast:192.168.1.255  
Mask:255.255.255.0  
inet6 addr: fe80::4a5b:39ff:fe86:b009/64 Scope:Link  
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1  
RX packets:367948 errors:0 dropped:0 overruns:0 frame:0  
TX packets:481279 errors:0 dropped:0 overruns:0 carrier:0  
collisions:0 txqueuelen:1000  
RX bytes:26453570 (26.4 MB) TX bytes:707562874 (707.5 MB)  
Interrupt:41 Base address:0x6000

And here you can see nginx has not logged any file access today. This  
is where the log ends, I have not accessed the server today.  
99.99.99.99 was my wife accessing the URL I sent her for this file she  
was trying to get to her friend, she clicked the link I emailed her,  
which was to our external IP on port 8000 (residential VDSL, incoming 80  
is blocked).

192.168.1.104 - - [27/Oct/2011:22:46:34 -0500] “GET / HTTP/1.1” 200 133  
“-” “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101  
Firefox/8.0”  
192.168.1.104 - - [27/Oct/2011:22:46:34 -0500] “GET /favicon.ico  
HTTP/1.1” 200 133 “-” “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0)  
Gecko/20100101 Firefox/8.0”  
192.168.1.104 - - [27/Oct/2011:22:46:34 -0500] “GET /favicon.ico  
HTTP/1.1” 200 133 “-” “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0)  
Gecko/20100101 Firefox/8.0”  
192.168.1.104 - - [27/Oct/2011:22:50:27 -0500] “GET /file.zip HTTP/1.1”  
200 194826552 “-” “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0)  
Gecko/20100101 Firefox/8.0”  
192.168.1.104 - - [27/Oct/2011:22:53:52 -0500] “GET /file.zip HTTP/1.1”  
200 154165552 “-” “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0)  
Gecko/20100101 Firefox/8.0”  
99.99.99.99 - - [27/Oct/2011:22:58:42 -0500] “GET /file.zip HTTP/1.1”  
200 24232852 “-” “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1)  
Gecko/20100101 Firefox/7.0.1”

Posted at Nginx Forum:

> **[nginx not logging access](https://forum.nginx.org/read.php?2,217477,217477#msg-217477)**
>
> It does seem to be logging some access (on my local network and then looping back in from my router's IP), but I'm not seeing access from someone external to my house. I can see that a connection exists in netstat, I can see my transmitted bytes...

---

<div class="post-metadata">

**Author:** ![cob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9bcb4/32.png) [@cob](https://www.ruby-forum.com/u/cob)\
**Post date:** [October 28, 2011, 9:33pm UTC](https://www.ruby-forum.com/t/nginx-not-logging-access/213280/2 "2011-10-28T21:33:37Z")

</div>

I just noticed that after the user’s download was complete, the  
access.log was updated. Not sure I particularly like that  
behavior…I’d prefer to have it logged when contact is initiated.

Posted at Nginx Forum:

> **[Re: nginx not logging access](https://forum.nginx.org/read.php?2,217477,217483#msg-217483)**
>
> It does seem to be logging some access (on my local network and then looping back in from my router's IP), but I'm not seeing access from someone external to my house. I can see that a connection exists in netstat, I can see my transmitted bytes...

---

<div class="post-metadata">

**Author:** ![cob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9bcb4/32.png) [@cob](https://www.ruby-forum.com/u/cob)\
**Post date:** [October 29, 2011, 12:27am UTC](https://www.ruby-forum.com/t/nginx-not-logging-access/213280/3 "2011-10-29T00:27:03Z")

</div>

Ok, guess I’ve just never noticed this with Apache or lighttpd. It  
would be nice to have a config option to log on-access instead, but I  
appreciate the info.

Posted at Nginx Forum:

> **[Re: nginx not logging access](https://forum.nginx.org/read.php?2,217477,217494#msg-217494)**
>
> It does seem to be logging some access (on my local network and then looping back in from my router's IP), but I'm not seeing access from someone external to my house. I can see that a connection exists in netstat, I can see my transmitted bytes...

---

<div class="post-metadata">

**Author:** ![cob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9bcb4/32.png) [@cob](https://www.ruby-forum.com/u/cob)\
**Post date:** [October 28, 2011, 10:15pm UTC](https://www.ruby-forum.com/t/nginx-not-logging-access/213280/4 "2011-10-28T22:15:01Z")

</div>

Hello!

On Fri, Oct 28, 2011 at 03:33:13PM -0400, cob wrote:

> I just noticed that after the user’s download was complete, the  
> access.log was updated. Not sure I particularly like that  
> behavior…I’d prefer to have it logged when contact is initiated.

Typical behaviour of http servers (and nginx isn’t an exception) is  
to log request once response is sent.

With current state of http as used for almost everything,  
including long streaming and so on, it’s probably good idea to  
have an option to log request once it’s got from client. Though  
it’s not something we currently have.

Maxim D.
