Skip to content

Access Logger ​

Sword can log one line per RPC once the response is sent. The line includes the path, the gRPC status code, the latency and the request id. This is separate from the global [tracing] subscriber and is driven entirely by the [grpc.logger] section.

The logger is off unless the section is present.

Configuration ​

toml
[grpc.logger]
enabled = true
level = "auto"
skip-paths = [
  "/grpc.health.v1.Health/Check",
  "/grpc.reflection.v1.ServerReflection/ServerReflectionInfo",
]
KeyTypeDefaultDescription
enabledbooltrueEnables or disables the logger
levelauto | infoautoLog level policy. See Levels
skip-pathsString[][]RPC paths to exclude from logging (exact or prefix match)

Levels ​

  • info logs every RPC at INFO regardless of the status code.
  • auto picks the level from the gRPC status code read from the grpc-status response header.
CodeLevel
OkINFO
client errorsWARN
server errors (the rest)ERROR

Log fields ​

FieldDescription
statusgRPC status code, rendered from Code (for example Ok, InvalidArgument).
latencyTime spent handling the RPC, formatted from Duration (e.g. 1.234ms).
request_idx-request-id value, or - when the header is missing.
rpcRPC path, for example /users.UserService/GetUser.

RPCs matching skip-paths are neither measured nor logged.

Request Identifier ​

The logger reuses the x-request-id header set by the built-in RequestIdLayer, which is also applied to gRPC requests for correlation. The full value is logged. When the header is missing, it uses a - placeholder.