I have multiple NGINX servers running multiple vhosts and I use a program called goaccess for data usage reports and site traffic reports. I have a small config in /etc/nginx/conf.d:
log_format vhost_combined '$server_name: $remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
access_log /var/www/combined-access.log vhost_combined;
I tested one of our sites by downloading a video file and watching the logs for GET requests to that file and noticed no traffic reported in the /var/www/combined-access.log but traffic is reported in the log file /var/log/nginx/xxxxxxxxxxxxx.access.log. Without context this should make sense, the site config should take presidence over nginx.conf. But that doesn’t explain:
- Why was it working until changing the log location
- Why are some requests for the site still getting logged in combined-access.log while all others are missing.
Additionally, commenting out the access_log line from the site config makes requests show up in the log file; however, is there a way to allow nginx to log to multiple locations without having conflicts in the configuration?