aboutsummaryrefslogtreecommitdiffstats
path: root/custom/conf
diff options
context:
space:
mode:
authorsillyguodong <33891828+sillyguodong@users.noreply.github.com>2023-03-10 23:54:32 +0800
committerGitHub <noreply@github.com>2023-03-10 09:54:32 -0600
commit5155ec35c571de8df62318df78c78cebc20e1aa0 (patch)
tree637594f6e7459bfdc625f8dac679d050838a4750 /custom/conf
parentcf29ee6dd290525635a0e1b823506e81f845b978 (diff)
downloadgitea-5155ec35c571de8df62318df78c78cebc20e1aa0.tar.gz
gitea-5155ec35c571de8df62318df78c78cebc20e1aa0.zip
Parse external request id from request headers, and print it in access log (#22906)
Close: #22890. --- ### Configure in .ini file: ```ini [log] REQUEST_ID_HEADERS = X-Request-ID, X-Trace-Id ``` ### Params in Request Header ``` X-Trace-ID: trace-id-1q2w3e4r ``` ![image](https://user-images.githubusercontent.com/33891828/218665296-8fd19a0f-ada6-4236-8bdb-f99201c703e8.png) ### Log output: ![image](https://user-images.githubusercontent.com/33891828/218665225-cc242a57-4ffc-449a-a1f6-f45ded0ead60.png)
Diffstat (limited to 'custom/conf')
-rw-r--r--custom/conf/app.example.ini16
1 files changed, 16 insertions, 0 deletions
diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index b7875c12dd..c3c20a216c 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -576,6 +576,22 @@ ROUTER = console
;; The routing level will default to that of the system but individual router level can be set in
;; [log.<mode>.router] LEVEL
;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Print request id which parsed from request headers in access log, when access log is enabled.
+;; * E.g:
+;; * In request Header: X-Request-ID: test-id-123
+;; * Configuration in app.ini: REQUEST_ID_HEADERS = X-Request-ID
+;; * Print in log: 127.0.0.1:58384 - - [14/Feb/2023:16:33:51 +0800] "test-id-123"
+;;
+;; If you configure more than one in the .ini file, it will match in the order of configuration,
+;; and the first match will be finally printed in the log.
+;; * E.g:
+;; * In reuqest Header: X-Trace-ID: trace-id-1q2w3e4r
+;; * Configuration in app.ini: REQUEST_ID_HEADERS = X-Request-ID, X-Trace-ID, X-Req-ID
+;; * Print in log: 127.0.0.1:58384 - - [14/Feb/2023:16:33:51 +0800] "trace-id-1q2w3e4r"
+;;
+;; REQUEST_ID_HEADERS =
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;