nginx 日志格式
log_format 有個默認的日志格式:
log_format combined '$remote_addr - $remote_user [$time_local]'
' "$request" $status $body_bytes_sent '
' "$http_referer" $http_user_agent"';
** nginx 默認調用 combined 格式來記錄日志,即默認調用:(默認記錄在access.log文件中)**
access_log logs/access.log combined;
nginx允許自定義日志格式,例如:
log_format main '$remote_addr - $remote_user [$time_local] "$http_host" "$request"'
'$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for $request_time';
以上是自定義了日志格式:main(main名稱可以自定義)
要想使其生效,就必須用access_log指定調用:
access_log logs/xx.log main;
否則,nginx仍然會去調用combined格式來記錄日志。