Skip to content

Commit edf0375

Browse files
fix: use apisix_request_id only in http subsystem log format (#13006)
1 parent bf15840 commit edf0375

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎apisix/cli/config.lua‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ local _M = {
111111
enable_access_log = false,
112112
access_log = "logs/access_stream.log",
113113
-- luacheck: push max code line length 300
114-
access_log_format = "$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time $apisix_request_id",
114+
access_log_format = "$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time",
115115
-- luacheck: pop
116116
access_log_format_escape = "default",
117117
lua_shared_dict = {
@@ -136,7 +136,7 @@ local _M = {
136136
access_log_buffer = 16384,
137137
-- luacheck: push max code line length 300
138138
access_log_format =
139-
'$remote_addr - $remote_user [$time_local] $http_host "$request" $status $body_bytes_sent $request_time "$http_referer" "$http_user_agent" $upstream_addr $upstream_status $upstream_response_time "$upstream_scheme://$upstream_host$upstream_uri"',
139+
'$remote_addr - $remote_user [$time_local] $http_host "$request" $status $body_bytes_sent $request_time "$http_referer" "$http_user_agent" $upstream_addr $upstream_status $upstream_response_time "$upstream_scheme://$upstream_host$upstream_uri" "$apisix_request_id"',
140140
-- luacheck: pop
141141
access_log_format_escape = "default",
142142
keepalive_timeout = "60s",

‎t/cli/test_access_log.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ curl http://127.0.0.1:9080/hello2
158158
sleep 4
159159
tail -n 1 logs/access.log > output.log
160160

161-
if [ `grep -E '[0-9|.]+ - - \[[^]]+\] [0-9|.:]+ "[^"]+" [0-9]+ [0-9]+ [0|.]+ "-" "[^"]+" - - - "[^"]+" ".{36}"' output.log` -eq '0' ]; then
161+
if [ `grep -E '"[0-9a-zA-Z]{32}"$' output.log` -eq '0' ]; then
162162
echo "failed: access log don't match default log format"
163163
exit 1
164164
fi

0 commit comments

Comments
 (0)