node01
Create a new file /etc/nginx/conf.d/extended-logs.conf
and add:
log_format main_ext '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$host" sn="$server_name" '
'rt=$request_time '
'ua="$upstream_addr" us="$upstream_status" '
'ut="$upstream_response_time" ul="$upstream_response_length" '
'cs=$upstream_cache_status' ;
And modify the lines access_log
and error_log
directives on /etc/nginx/sites-available/example.com
accordingly following the example below.
From:
access_log /var/log/nginx/example.com.access.log rt_cache;
error_log /var/log/nginx/example.com.error.log;
To:
access_log /var/log/nginx/example.com.access.log main_ext;
error_log /var/log/nginx/example.com.error.log warn;
After the changes, run nginx -t && service nginx reload
(or nginx -t && service nginx restart
if you want to forcedly disconnect all connections in progress). Confirm no errors were output when running this command.
After confirming everything is working as expected, you may also want to comment out some (or all) access_log off;
occurrences in all .conf files in /etc/nginx/common/
directory depending on the metrics you want (WordOps disables access logs for several kind of static files by default). You can just add #
in front of these lines to make them ineffective and run the command above to reload Nginx settings again.