Posted at

nginx のアクセスログを LTSV にする

More than 5 years have passed since last update.

nginx.conf から抜粋です。

    log_format  ltsv  "time:$time_local"

"\thost:$remote_addr"
"\tforwardedfor:$http_x_forwarded_for"
"\tuser:$remote_user"
"\treq:$request"
"\tstatus:$status"
"\tsize:$body_bytes_sent"
"\treferer:$http_referer"
"\tua:$http_user_agent"
"\treqtime:$request_time"
"\tcache:$upstream_http_x_cache"
"\truntime:$upstream_http_x_runtime"
"\tapptime:$upstream_response_time"
"\tvhost:$host";

access_log logs/access.log ltsv;

項目は必要に応じて増減するといい感じ。