9951 explained code solutions for 126 technologies

nginxHow to log total time request took

http {
  log_format timings '[$time_local] $remote_addr: "$request" $request_time s';
  # ...
  server {
    # ...
    access_log /var/log/nginx/api.log timings;ctrl + c
log_format timings

define named log format


full date time of request


client IP address


full HTTP request string


time request took to process and return response (3 decimals)


sets log file path and format (timings in our case)