mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-05 18:05:19 +02:00
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 ```  ### Log output: 
This commit is contained in:
parent
cf29ee6dd2
commit
5155ec35c5
5 changed files with 74 additions and 1 deletions
|
@ -881,7 +881,13 @@ Default templates for project boards:
|
|||
- `Identity`: the SignedUserName or `"-"` if not logged in.
|
||||
- `Start`: the start time of the request.
|
||||
- `ResponseWriter`: the responseWriter from the request.
|
||||
- `RequestID`: the value matching REQUEST_ID_HEADERS(default: `-`, if not matched).
|
||||
- You must be very careful to ensure that this template does not throw errors or panics as this template runs outside of the panic/recovery script.
|
||||
- `REQUEST_ID_HEADERS`: **\<empty\>**: You can configure multiple values that are splited by comma here. It will match in the order of configuration, and the first match will be finally printed in the access log.
|
||||
- e.g.
|
||||
- In the 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**" ...
|
||||
|
||||
### Log subsections (`log.name`, `log.name.*`)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue