As we have seen before, Nginx allows you to easily set up a logging format. In this recipe, we will explore how one configuration file can exploit multiple logging formats. This neat functionality can help you generate custom logs specific to a particular section of the site whenever necessary.
This particular configuration will implement three logging formats and then effectively utilize them for logging different sections of the site:
http { log_format main '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; # You do not need HTTP authentication information and Refer information for the static files ! log_format static_main '$remote_addr [$time_local] ' '"$request" $status $body_bytes_sent '"$http_user_agent"; # You do not need to know about the bytes sent in an...