Application focused logging
In this recipe, we're going to customize the logs to give us a bit more information when it comes to applications and metrics. Additional information, such as the response time, can be immensely useful for measuring the responsiveness of your application. While it can generally be generated within your application stack, it can also induce some overhead or give incomplete results.
How to do it...
To start with, we need to define our new log format:
log_format applogs '$remote_addr $remote_user $time_iso8601' '"$request" $status $body_bytes_sent ' '$request_time $upstream_response_time';
Note
The log_format
directive needs to be outside the server
block.
Here, we've deviated from the combined format to change the time to the ISO 8601 format (which will look something like 2016-07-16T21:48:36+00:00
), removed the HTTP referrer and user agent, but added the request processing time ($request_time
) to get a better idea on how much...