log_config

The log_config section controls how the YDB server process handles and manages its logs. It allows you to configure logging levels for various components, as well as global log formats and output methods.

Note

This document describes application and system logging configuration. For information on logging for audit and security purposes, see Audit log.

Overview

Logging is a critical part of the YDB observability system. The log_config section allows you to configure various aspects of logging, including:

  • default logging level;
  • logging levels for specific components;
  • log output format;
  • integration with syslog or external logging services.

Log Output Methods

  • To stderr: by default, YDB sends all logs to stderr.
  • To file: logs can be written to a file using the backend_file_name parameter.
  • To syslog: when the sys_log: true parameter is enabled, logs are redirected to the system syslog and stop being output to stderr. Logs are sent using the /dev/log socket.
  • To Unified Agent: when configuring the uaclient_config section, logs are sent to Unified Agent and stop being output to stderr.

When both sys_log and uaclient_config are enabled simultaneously, logs will be sent to both syslog and Unified Agent. If you need to continue outputting logs to stderr while using other methods, activate sys_log_to_stderr: true.

Configuration Options

Parameter Type Default Description
default_level uint32 5 (NOTICE) Default logging level for all components.
default_sampling_level uint32 7 (DEBUG) Default sampling level for all components.
default_sampling_rate uint32 0 Default sampling rate for all components. If set to N (where N > 0), approximately 1 out of every N log messages with priority between default_level and default_sampling_level will be logged. For example, to log every 10th message, set to 10. A value of 0 means that messages in this range will not be logged (all of them are dropped).
sys_log bool false Enable logging via syslog.
sys_log_to_stderr bool false Copy logs to stderr in addition to syslog.
format string "full" Log output format. Possible values: "full", "short", "json".
cluster_name string — Cluster name to include in log records. The cluster_name field is added to logs only when using the json format or when sending to Unified Agent. In the full or short formats, this field is not displayed.
allow_drop_entries bool true Allow dropping log entries if the logging system is overloaded. When this option is enabled, log entries are buffered in memory and written to the output when 10 messages accumulate or the time specified in time_threshold_ms elapses. If the buffer becomes full, low-priority messages may be dropped to make room for higher-priority messages.
use_local_timestamps bool false Use local time zone for log timestamps (UTC is used by default).
backend_file_name string — File name for log output. If specified, logs are written to this file.
sys_log_service string — Service name for syslog. Corresponds to the tag field in the old syslog protocol RFC 3164 or the app-name field in the modern protocol RFC 5424.
time_threshold_ms uint64 1000 If allow_drop_entries = true, specifies how often, in milliseconds, YDB writes buffered log entries to the output.
ignore_unknown_components bool true Ignore logging requests from unknown components.
entry array [] Configuration of logging level and/or sampling for specific YDB components, see Entry Objects below.
uaclient_config object — Configuration for the Unified Agent client, see UAClientConfig Object below.
enable_structured_log_in_json bool false When outputting the log in json format: if false, the message text (the message field) contains structured values as key=value (for example, Text (a=1 b=2)); if true, the message field contains only the text, and structured values are output as separate string JSON fields (for example, {"message":"Text","a":"1","b":"2"}). Reserved field names get the _ prefix.

Entry Objects

Note

Logging in YDB assumes that the system consists of a large number of internal components, each of which has its own unique code assigned. You can find the full list of components and their codes on GitHub.

When writing a message to the log, the component code on whose behalf the message is written must be explicitly or implicitly specified. Subsequently, the component name is output to the log and can be used to search or filter log content.

The entry field allows you to set logging parameters for individual components. It contains an array of objects with the following structure:

Parameter Type Description
component string Component name. See the full list of available components on GitHub.
level uint32 Log level for this component.
sampling_level uint32 Sampling level for this component. Works similarly to default_sampling_level.
sampling_rate uint32 Sampling rate for this component. Works similarly to default_sampling_rate.

UAClientConfig Object

The uaclient_config field configures integration with Unified Agent:

Parameter Type Default Description
uri string — grpc URI of the Unified Agent server.
shared_secret_key string — Path to the file with the secret key for authenticating client connections.
max_inflight_bytes uint64 100000000 Maximum number of bytes in transit when sending data.
grpc_reconnect_delay_ms uint64 — Delay between reconnection attempts in milliseconds.
grpc_send_delay_ms uint64 — Delay between send attempts in milliseconds.
grpc_max_message_size uint64 — Maximum gRPC message size.
client_log_file string — Log file for the UA client itself.
client_log_priority uint32 — Logging level for the UA client itself.
log_name string — Log name that is passed in session metadata.

Log Levels

YDB uses the following log levels, listed from the highest to the lowest severity:

Level Numeric value Description
EMERG 0 System failure is possible (for example, cluster failure).
ALERT 1 System degradation is possible, system components may fail.
CRIT 2 Critical state.
ERROR 3 Non-critical error.
WARN 4 A warning that should be responded to and fixed unless it is temporary.
NOTICE 5 An event essential for the system or the user has occurred.
INFO 6 Debugging information for collecting statistics.
DEBUG 7 Debugging information for developers.
TRACE 8 Very detailed debugging information.

Examples

Basic Configuration

log_config:
  default_level: 5  # NOTICE
  format: "full"

This configuration outputs logs to stderr with logging level NOTICE and above.

Configuration with File Output

log_config:
  default_level: 5  # NOTICE
  format: "full"
  backend_file_name: "/var/log/ydb/ydb.log"

This configuration sends logs to a file while maintaining the default logging level of NOTICE.

Configuration with Syslog Output

log_config:
  default_level: 5  # NOTICE
  sys_log: true
  sys_log_service: "ydb"
  format: "full"

This configuration sends logs to syslog with the service name "ydb".

Setting Log Levels for Individual Components

log_config:
  default_level: 5  # NOTICE
  entry:
    - component: "SCHEMESHARD"
      level: 7  # DEBUG
    - component: "TABLET_MAIN"
      level: 6  # INFO
  backend_file_name: "/var/log/ydb/ydb.log"

Enabling Transaction Lock Invalidation Diagnostics (TLI)

To diagnose transaction locks invalidated errors, enable logging for the TLI component:

log_config:
  entry:
    - component: "TLI"
      level: 6  # INFO

Once enabled, the server writes logs on every lock conflict, including identifiers and query texts of both victims and violators. For details on the log entry format, event correlation, and the find_tli_chain utility, see TLI Logging.

Sampling Configuration

log_config:
  default_level: 5  # NOTICE
  default_sampling_level: 7  # DEBUG
  default_sampling_rate: 10  # Log every 10th message between NOTICE and DEBUG
  entry:
    - component: "BLOBSTORAGE"
      sampling_level: 8  # TRACE
      sampling_rate: 100  # Log every 100th message between NOTICE and TRACE

This configuration sets up log sampling. With default settings, every 10th message with priority between NOTICE and DEBUG will be logged. For the BLOBSTORAGE component, every 100th message with priority between NOTICE and TRACE will be logged.

JSON Format Configuration

log_config:
  default_level: 5  # NOTICE
  format: "json"
  cluster_name: "production-cluster"
  uaclient_config:
    uri: "[fd53::1]:16400"
    grpc_max_message_size: 4194304
    log_name: "ydb_logs"

This configuration outputs logs in JSON format and sends them to Unified Agent.

Notes

  • Log levels are specified in the configuration as numeric values, not strings. Use the table above to map between numeric values and their meanings.
  • If the backend_file_name parameter is specified, logs are written to this file. If the sys_log parameter is true, logs are sent to the system logger.
  • The format parameter determines how log entries are formatted. The "full" format includes all available information, "short" provides a more compact format, and "json" outputs logs in JSON format, which is convenient for parsing by logging services.
  • The internal log buffer has the following size limits:
    • Default total size: 10MB (10 * 1024 * 1024 bytes)
    • Default grain size: 64KB (1024 * 64 bytes)
    • Maximum message size: 1KB (1024 bytes)

See Also