You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6acc686
Browse filesBrowse the repository at this point in the historyBrowse files
docs: one per-request log line with the response status (v3) (#17)
* docs: one per-request log line with the response status (v3)
* docs: sync per-request logging with the merged code (v3)
---------
Co-authored-by: Jose Quintana <joseluisquintana20@gmail.com>
Copy file name to clipboardExpand all lines: src/v3/configuration/cli.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,7 @@ Options:
105
105
--access-log-format <ACCESS_LOG_FORMAT>
106
106
Custom access log format string using %{token} syntax. When set, replaces the default request logging with a configurable format that includes response data. Tokens: method, uri, status, bytes, duration, remote_addr, x_real_ip, forwarded_for, host, user_agent, referer, timestamp, version. x_real_ip and forwarded_for are logged only for requests from --trusted-proxies, if set. Example: '%{remote_addr} "%{method} %{uri}" %{status} %{bytes}' [env: SERVER_ACCESS_LOG_FORMAT=] [default: ""]
107
107
--log-remote-address [<LOG_REMOTE_ADDRESS>]
108
-
Log incoming requests information along with its remote address if available using the `info` log level [env: SERVER_LOG_REMOTE_ADDRESS=] [default: false] [possible values: true, false]
108
+
Log the remote address of each request, if available [env: SERVER_LOG_REMOTE_ADDRESS=] [default: false] [possible values: true, false]
109
109
--log-x-real-ip [<LOG_X_REAL_IP>]
110
110
Log the X-Real-IP header for remote IP information [env: SERVER_LOG_X_REAL_IP=] [default: false] [possible values: true, false]
2026-05-29T23:44:04.703047+02:00 INFO static_web_server::server: starting Static Web Server name="static-web-server" version="2.42.0"
60
60
2026-05-29T23:44:04.704137+02:00 INFO static_web_server::compression: auto compression enabled=true formats=deflate,gzip,brotli,zstd compression_level=Default
61
-
2026-05-29T23:44:05.724579+02:00 INFO static_web_server::log_addr: incoming request method=GET uri=/
61
+
2026-05-29T23:44:05.724579+02:00 INFO static_web_server::log_addr: response method=GET uri=/ status=200
When the level is `info` or lower, SWS logs each request with the `incoming request` message. Requests to the [health endpoints](./health-endpoint.md) (`/livez` and `/readyz`) are logged at `debug` level instead, to avoid noise from frequent probes.
93
+
When the level is `info` or lower, SWS logs one line per request with the `response` message, once the response body is sent or aborted. The line carries the request method, the URI as sent by the client (before [URL Rewrites](./url-rewrites)) and the response `status`, including for responses that end the request early, such as redirects or `405 Method Not Allowed`. Requests to the [health endpoints](./health-endpoint.md) (`/livez` and `/readyz`) are logged at `debug` level instead, to avoid noise from frequent probes.
94
94
95
95
```json
96
96
{
97
97
"timestamp": "2026-05-29T23:43:47.151533+02:00",
98
98
"level": "INFO",
99
-
"message": "incoming request",
99
+
"message": "response",
100
100
"method": "GET",
101
101
"uri": "/",
102
+
"status": 200,
102
103
"target": "static_web_server::log_addr"
103
104
}
104
105
```
105
106
106
-
The `remote_addr`, `x_real_ip` and `real_remote_ip` fields are added when the corresponding logging options are enabled and a value is available. Fields without a value are omitted.
107
+
No line is logged when SWS fails to build a response. The `remote_addr`, `x_real_ip` and `real_remote_ip` fields are added when the corresponding logging options are enabled and a value is available. Fields without a value are omitted.
107
108
108
109
## Log Remote Addresses
109
110
@@ -117,7 +118,7 @@ static-web-server -a "0.0.0.0" -p 8080 -d docker/public/ -g info --log-remote-ad
117
118
118
119
```json
119
120
{"timestamp":"2026-05-29T23:43:47.071681+02:00","level":"INFO","message":"log requests with remote IP addresses","enabled":true,"target":"static_web_server::log_addr"}
**`SWS`** can write one access log line per request in a format you define, for example the nginx or NCSA combined format. The line is written when the response body is finished, so it carries the status code, the number of body bytes sent and the duration of the whole transfer.
236
241
237
-
This feature is disabled by default. Set a format with the `--access-log-format` option, the equivalent [SERVER_ACCESS_LOG_FORMAT](./../configuration/env#server_access_log_format) env or the `access-log-format` key under `[general]` in the [TOML file](./../configuration/file). When a format is set, it replaces the `incoming request` line described in [Per-request logging](#per-request-logging).
242
+
This feature is disabled by default. Set a format with the `--access-log-format` option, the equivalent [SERVER_ACCESS_LOG_FORMAT](./../configuration/env#server_access_log_format) env or the `access-log-format` key under `[general]` in the [TOML file](./../configuration/file). When a format is set, it replaces the `response` line described in [Per-request logging](#per-request-logging).
0 commit comments