• Start

Logging

Server log levels, text and JSON formats, file and socket output, slow-query logging, and OpenTelemetry log levels.

SurrealDB writes server logs to stderr by default. You can set flags on surreal start or the matching environment variables and ship lines to your collector or log store.

ConcernCLI flag (examples)Environment variable (examples)
Level--logSURREAL_LOG
Format--log-format (text or json)SURREAL_LOG_FORMAT
Remote socket--log-socketSURREAL_LOG_SOCKET
File logging--log-file-enabled, --log-file-path, --log-file-rotation, …SURREAL_LOG_FILE_ENABLED, SURREAL_LOG_FILE_PATH, SURREAL_LOG_FILE_ROTATION, …
File level--log-file-levelSURREAL_LOG_FILE_LEVEL
Slow queries--slow-log-threshold, --slow-log-param-allow, --slow-log-param-denySURREAL_SLOW_QUERY_LOG_THRESHOLD, SURREAL_SLOW_QUERY_LOG_PARAM_ALLOW, SURREAL_SLOW_QUERY_LOG_PARAM_DENY

Further socket and file options (--log-socket-level, --log-file-name, --log-file-format, and others) are documented on surreal start and in Environment variables.

Slow-query logging records statements that exceed your threshold. The --slow-log-param-allow / --slow-log-param-deny flags control whether bound parameters are expanded in the log line (for example turning SELECT * FROM $table_name into SELECT * FROM person when table_name is allowed), the use of which is recommended for any logs that may contain sensitive data.

OpenTelemetry trace output can be tuned separately from ordinary server logs:

  • --log-otel-level or SURREAL_LOG_OTEL_LEVEL — verbosity of OTel-related tracing output.

When OTLP is enabled, SurrealDB Enterprise can also emit audit and slow-query records as OpenTelemetry logs when you set SURREAL_AUDIT_OTEL_EXPORT / SURREAL_SLOW_QUERY_OTEL_EXPORT. Severity mapping and dual paths (file sink versus OTLP) are summarised on Observability (metrics and Prometheus), Enterprise observability, and in the Metrics reference. In-tree detail lives in doc/OBSERVABILITY.md on GitHub.

Was this page helpful?