# Nginx logging conundrum

**URL:** <https://www.ruby-forum.com/t/nginx-logging-conundrum/210462>\
**Category:** NGINX\
**Created:** [August 9, 2011, 7:31am UTC](https://www.ruby-forum.com/t/nginx-logging-conundrum/210462 "2011-08-09T07:31:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [August 9, 2011, 7:31am UTC](https://www.ruby-forum.com/t/nginx-logging-conundrum/210462/1 "2011-08-09T07:31:26Z")

</div>

I need some enlightenment from some savants here.  
My issue is I can’t seem to get logging to work besides logging to  
/var/log/messages. I originally installed the non-devel port on freebsd  
8.2,  
which actually logged to nginx-error.log for a little, until I started  
tweaking the config file more to my setup. I originally intended to  
override  
the log path compile options in the config file by pointing to  
/var/log/www/nginx-access.log I never was able to get any logging to  
this  
file though. So I went back to having the path in the config file match  
the  
compile options - /var/log/nginx-access.log  
Still no logging to this file and no files created. So I touched the  
files  
thinking maybe… That didn’t work and than I did a chmod/chown on the  
files  
hoping that was the issue. Still no logging and by this time no errors  
logging either. I only get the output in messages.  
I have done a lsof looking to see if any files are open yet I’m not too  
“bright” and didn’t see any output showing logging.  
I’ve looked at my syslog.conf/newsyslog.conf and didn’t see any help  
there.  
I’ve attempted to have both global and server log configurations and  
neither  
seem to do anything for me currently.  
I am currently running nginx -V  
nginx: nginx version: nginx/1.1.0  
nginx: TLS SNI support enabled  
nginx: configure arguments: --prefix=/usr/local/etc/nginx  
–with-cc-opt=‘-I  
/usr/local/include’ --with-ld-opt=‘-L /usr/local/lib’  
–conf-path=/usr/local/etc/nginx/nginx.conf  
–sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid  
–error-log-path=/var/log/nginx-error.log --user=www --group=www  
–with-file-aio --with-ipv6  
–http-client-body-temp-path=/var/tmp/nginx/client\_body\_temp  
–http-fastcgi-temp-path=/var/tmp/nginx/fastcgi\_temp  
–http-proxy-temp-path=/var/tmp/nginx/proxy\_temp  
–http-scgi-temp-path=/var/tmp/nginx/scgi\_temp  
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi\_temp  
–http-log-path=/var/log/nginx-access.log  
–add-module=/usr/ports/www/nginx-devel/work/giom-nginx\_accept\_language\_module-02262ce  
–add-module=/usr/ports/www/nginx-devel/work/ngx\_http\_auth\_request\_module-0.2  
–add-module=/usr/ports/www/nginx-devel/work/agentzh-headers-more-nginx-module-137855d  
–with-http\_dav\_module  
–add-module=/usr/ports/www/nginx-devel/work/ngx-fancyindex-0.3.1  
–add-module=/usr/ports/www/nginx-devel/work/ngx\_http\_gunzip\_filter\_module-0.3  
–with-http\_flv\_module --with-http\_geoip\_module  
–with-http\_gzip\_static\_module --with-http\_image\_filter\_module  
–with-http\_perl\_module --with-http\_realip\_module --with-http\_ssl\_module  
–with-http\_stub\_status\_module  
–add-module=/usr/ports/www/nginx-devel/work/nginx\_upload\_module-2.2.0  
–add-module=/usr/ports/www/nginx-devel/work/nginx\_uploadprogress\_module-0.8.2  
–with-http\_xslt\_module  
–add-module=/usr/ports/www/nginx-devel/work/mod\_zip-1.1.6  
–add-module=/usr/ports/www/nginx-devel/work/agentzh-memc-nginx-module-4f1952c  
–with-pcre --with-syslog --with-syslog-facility=LOG\_DAEMON  
–add-module=/usr/ports/www/nginx-devel/work/nginx\_udplog\_module-1.0.0  
–add-module=/usr/ports/www/nginx-devel/work/agentzh-xss-nginx-module-8618dd3

My .conf file which probably has other issues with it as well. As I  
mentioned I have attempted several different paths for loggin in this  
config  
file and tried to remove paths to see if that made any difference.  
user www www;  
worker\_processes 1;

events{ worker\_connections 1024;  
}  
http {  
include mime.types;  
default\_type application/octet-stream;  
log\_format main '$remote\_addr - $remote\_user [$time\_local]  
“$request” ’  
'$status $body\_bytes\_sent “$http\_referer” ’  
‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;  
access\_log /var/log/nginx-access.log main;  
sendfile on;  
tcp\_nopush on;  
tcp\_nodelay on;  
#keepalive\_timeout 0;  
keepalive\_timeout 65;  
gzip on;  
gzip\_static on;  
gzip\_buffers 16 8k;  
gzip\_comp\_level 6;  
gzip\_http\_version 1.0;  
gzip\_types text/plain text/css image/x-icon image/bmp;  
gzip\_vary on;  
gzip\_min\_length 1100;

server {  
server\_name [www.xxx.com](http://www.xxx.com) [xxx.com](http://xxx.com);  
listen 80;  
listen 443 ssl;  
root /usr/local/www/crafty;  
index index.php index.html index.htm;  
ssl\_certificate /usr/local/etc/ssl/server.crt;  
ssl\_certificate\_key /usr/local/etc/ssl/server.key;  
ssl\_session\_timeout 5m;  
ssl\_protocols SSLv2 SSLv3 TLSv1;  
ssl\_ciphers HIGH:!aNULL:!MD5;  
ssl\_prefer\_server\_ciphers on;  
access\_log /var/log/nginx-access.host.log combined;  
error\_log /var/log/nginx-error.log error;

```
    location ~ \.htaccess {
            deny all;
    }

    location / {
            if (!-e $request_filename) {
                    rewrite ^/([^?]*)(?:\?(.*))? 

```

/index.php?title=$1&$2  
last;  
rewrite  
^/index.php/([a-z]+),([0-9]+).(\w+)/(\w+),(\w+)/(\w+).html  
/index.php?$1=$2.$3&$4=$5&$6 last;  
rewrite  
^/index.php/([a-z]+),([0-9]+).(\w+)/(\w+),(\w+).html  
/index.php?$1=$2.$3&$4=$5 last;  
rewrite  
^/index.php/([a-z]+),([0-9]+).(\w+)/(\w+)/(\w+).html  
/index.php?$1=$2.$3&$4&$5 last;  
rewrite  
^/index.php/([a-z]+),([0-9]+).(\w+)/(\w+).html /index.php?$1=$2.$3&$4  
last;  
rewrite  
^/index.php/([a-z]+),([0-9]+)/(\w+),(\w+).html /index.php?$1=$2&$3=$4  
last;  
rewrite  
^/index.php/([a-z]+),([0-9]+).(\w+).html  
/index.php?$1=$2.$3 last;  
}  
if ($uri ~\* “.(ico|css|js|gif|jpe?g|png)(?[0-9]+)?$”)  
{  
expires max;  
break;  
}  
error\_page 404 /404.html;  
location = /404.html {  
root /usr/local/www/crafty;  
}  
# redirect server error pages to the static page /50x.html  
#  
error\_page 500 502 503 504 /50x.html;  
location = /50x.html {  
root /usr/local/www/crafty;  
}

```
    }

    location ~* \.php$ {
            if (!-e $request_filename) {
                    return 404;
            }
            root /usr/local/www/crafty;
            include /usr/local/etc/nginx/fastcgi_params;
            #if ($uri !~ "^/images/") {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME

```

$document\_root$fastcgi\_script\_name;  
}  
}

}

my google powers have let me down and the only thing I have found in  
searching on this is issues with past versions but nothing for current.  
I have tried all methods of stopping/starting the daemon. From using the  
rc.d script to pkill to calling the binary -s to rebooting the server.  
I’m at a lost right now, I thought a reinstall of devel would help but  
I’m  
at the same place I was 30 hours ago.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 9, 2011, 7:54am UTC](https://www.ruby-forum.com/t/nginx-logging-conundrum/210462/2 "2011-08-09T07:54:17Z")

</div>

On Tue, Aug 9, 2011 at 1:30 AM, Mike L [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> thinking maybe.. That didn’t work and than I did a chmod/chown on the files  
> nginx: configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I  
> –http-log-path=/var/log/nginx-access.log  
> –add-module=/usr/ports/www/nginx-devel/work/nginx\_upload\_module-2.2.0  
> –add-module=/usr/ports/www/nginx-devel/work/nginx\_uploadprogress\_module-0.8.2  
> –with-http\_xslt\_module  
> –add-module=/usr/ports/www/nginx-devel/work/mod\_zip-1.1.6  
> –add-module=/usr/ports/www/nginx-devel/work/agentzh-memc-nginx-module-4f1952c  
> –with-pcre --with-syslog --with-syslog-facility=LOG\_DAEMON

Looks like you’ve told nginx to log to syslog, not a file, so you  
would need to set logging facility and location in the config for  
syslogd.  
If that’s not what you want, recompile without that option and you’ll  
get your log files back.

> events{ worker\_connections 1024;  
> }  
> http {  
> include mime.types;  
> default\_type application/octet-stream;  
> log\_format main '$remote\_addr - $remote\_user [$time\_local]  
> “$request” ’  
> '$status $body\_bytes\_sent “$http\_referer” ’  
> ‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;  
> access\_log /var/log/nginx-access.log main;

see

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

you need something like:  
error\_log /var/log/nginx-vhostname-error.log info;

for your included servers, or in nginx.conf somewhere.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 9, 2011, 8:05am UTC](https://www.ruby-forum.com/t/nginx-logging-conundrum/210462/3 "2011-08-09T08:05:24Z")

</div>

Thank you very much! I knew I overlooked something stupid. That was it  
exactly. Works as expected now.  
_embarrassed_ “More sleep less, I can finish this up any time now…”
