nginx自定义日志格式方法
nginx自定义日志格式方法
在 nginx.conf文件http、server里面定义
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format ldygo
'$remote_addr|[$time_local]|$request_method|$content_length|$host|$request_uri|$status|'
'$request_time|$body_bytes_sent|$upstream_addr|$upstream_status|$upstream_response_time|'
'$http_referer|$http_x_forwarded_for|$http_user_agent';
log_format ldyfss
'$remote_addr|[$time_local]|$server_protocol|$request_method|$content_length|$host|$request_uri|$status|'
'$request_time|$body_bytes_sent|$upstream_addr|$upstream_status|$upstream_response_time|'
'$http_referer|$http_x_forwarded_for|$http_user_agent';
log_format logstash
'$remote_addr|$host|$request_uri|$status|$request_time|$body_bytes_sent|'
'$upstream_addr|$upstream_status|$upstream_response_time|'
'$http_referer|$http_x_forwarded_for|$http_user_agent';