From 2578c6250f59fdd3e10ac1438dd294ce9d29915b Mon Sep 17 00:00:00 2001 From: Vladimir Kutepov Date: Mon, 26 Oct 2026 09:47:29 +0700 Subject: [PATCH 1/8] docs: access log format (v3) --- src/v3/configuration/cli.md | 2 ++ src/v3/configuration/env.md | 4 +++ src/v3/configuration/file.md | 3 +++ src/v3/features/logging.md | 50 ++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) diff --git a/src/v3/configuration/cli.md b/src/v3/configuration/cli.md index 4642d32..8094dcd 100644 --- a/src/v3/configuration/cli.md +++ b/src/v3/configuration/cli.md @@ -100,6 +100,8 @@ Options: Defines a grace period in seconds after a `SIGTERM` signal is caught which will delay the server before to shut it down gracefully. The maximum value is 255 seconds [env: SERVER_GRACE_PERIOD=] [default: 0] -w, --config-file Server TOML configuration file path [env: SERVER_CONFIG_FILE=] [default: ./sws.toml] + --access-log-format + 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. Example: '%{remote_addr} "%{method} %{uri}" %{status} %{bytes}' [env: SERVER_ACCESS_LOG_FORMAT=] [default: ""] --log-remote-address [] 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] --log-x-real-ip [] diff --git a/src/v3/configuration/env.md b/src/v3/configuration/env.md index 1a85782..e2b721c 100644 --- a/src/v3/configuration/env.md +++ b/src/v3/configuration/env.md @@ -171,6 +171,10 @@ Defines a grace period in seconds after a `SIGTERM` signal is caught which will Server TOML configuration file path. See [The TOML Configuration File](../configuration/file). Default `./sws.toml`. +## SERVER_ACCESS_LOG_FORMAT + +Custom access log format using the `%{token}` syntax. When set, SWS logs one line per request after the response in this format, instead of the default request line. See [Access Log Format](../features/logging#access-log-format). Default empty (disabled). + ## SERVER_LOG_REMOTE_ADDRESS Log incoming requests information along with its remote address if available using the `info` log level. Default `false`. diff --git a/src/v3/configuration/file.md b/src/v3/configuration/file.md index 38ab096..69691a8 100644 --- a/src/v3/configuration/file.md +++ b/src/v3/configuration/file.md @@ -80,6 +80,9 @@ grace-period = 0 #### Page fallback for 404s # page-fallback = "" +#### Custom access log format (replaces the default request line when set) +# access-log-format = '%{remote_addr} - [%{timestamp}] "%{method} %{uri} %{version}" %{status} %{bytes} "%{referer}" "%{user_agent}"' + #### Log request Remote Address if available log-remote-address = false diff --git a/src/v3/features/logging.md b/src/v3/features/logging.md index 781ebee..1d9a4eb 100644 --- a/src/v3/features/logging.md +++ b/src/v3/features/logging.md @@ -230,6 +230,56 @@ curl "http://[::1]:8080" --header "X-Forwarded-For: