From 736c25f740fb3c8023b01edc4e71456c2621fdae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B0=8F=E4=BA=91?= Date: Mon, 19 May 2025 10:28:09 +0800 Subject: [PATCH] xx --- nginx/vhosts/logging.conf | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 nginx/vhosts/logging.conf diff --git a/nginx/vhosts/logging.conf b/nginx/vhosts/logging.conf new file mode 100644 index 0000000..437e66b --- /dev/null +++ b/nginx/vhosts/logging.conf @@ -0,0 +1,31 @@ +# 定义日志格式 +log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for" ' + '$request_time $upstream_response_time'; + +log_format json_combined escape=json '{' + '"timestamp":"$time_iso8601",' + '"remote_addr":"$remote_addr",' + '"remote_user":"$remote_user",' + '"request":"$request",' + '"status": "$status",' + '"body_bytes_sent":"$body_bytes_sent",' + '"http_referer":"$http_referer",' + '"http_user_agent":"$http_user_agent",' + '"http_x_forwarded_for":"$http_x_forwarded_for",' + '"request_time":"$request_time",' + '"upstream_response_time":"$upstream_response_time"' + '}'; + +# 访问日志配置 +access_log /var/log/nginx/access.log main buffer=32k flush=5s; +access_log /var/log/nginx/access.json.log json_combined buffer=32k flush=5s; + +# 错误日志配置 +error_log /var/log/nginx/error.log warn; + +# 开启压缩日志功能 +gzip on; +gzip_disable "msie6"; +gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript; \ No newline at end of file