nginx logging conundrum

Stefan Caunter stef at caunter.ca
Tue Aug 9 05:53:50 UTC 2011


On Tue, Aug 9, 2011 at 1:30 AM, Mike L <jackoroses at gmail.com> wrote:
> 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

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.

> --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;

see
http://wiki.nginx.org/CoreModule#error_log

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

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

>         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 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.
>



More information about the nginx mailing list