diff --git a/src/v3/configuration/cli.md b/src/v3/configuration/cli.md index ec237d7..f9bce37 100644 --- a/src/v3/configuration/cli.md +++ b/src/v3/configuration/cli.md @@ -102,6 +102,8 @@ Options: Defines the time in seconds after which a connection without any reads or writes is closed. An HTTP/1 request header must also arrive within this time. Use `0` to disable it. The maximum value is 65535 seconds [env: SERVER_IDLE_TIMEOUT=] [default: 30] -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. 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: ""] --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 5200df8..fa27822 100644 --- a/src/v3/configuration/env.md +++ b/src/v3/configuration/env.md @@ -175,6 +175,10 @@ Defines the time in seconds after which a connection without any reads or writes 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 3b08bb3..d8dea9b 100644 --- a/src/v3/configuration/file.md +++ b/src/v3/configuration/file.md @@ -83,6 +83,9 @@ idle-timeout = 30 #### 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 612d443..069fe2d 100644 --- a/src/v3/features/logging.md +++ b/src/v3/features/logging.md @@ -230,6 +230,63 @@ curl "http://[::1]:8080" --header "X-Forwarded-For: