Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex API Gateway
  • Getting started
    • All guides
    • Creating an API gateway
      • Updating API gateways and their specifications
      • Adding a domain
      • Specifying a cloud network
      • Setting up variables
      • Setting up a canary release
      • Viewing monitoring charts
        • Viewing logs
        • Writing logs
      • Removing a domain
      • Migration to the ru-central1-d availability zone
      • Deleting an API gateway
    • Viewing operations with service resources
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ

In this article:

  • Logging destination
  • Minimum logging level
  • Disabling logging
  • Command example
  • Logging destination
  • Minimum logging level
  • Disabling logging
  • Example
  1. Step-by-step guides
  2. Managing an API gateway
  3. Managing logs
  4. Writing logs

Writing to the execution log in API Gateway

Written by
Yandex Cloud
Updated at May 13, 2025
  • Logging destination
  • Minimum logging level
  • Disabling logging
  • Command example
  • Logging destination
  • Minimum logging level
  • Disabling logging
  • Example

Note

Logging is not free of charge. For more information, see the Yandex Cloud Logging documentation.

Management console
CLI
Terraform
API
  1. In the management console, go the folder containing the API gateway.
  2. In the list of services, select API Gateway.
  3. Select the API gateway you want to configure logging for.
  4. At the top of the page, click Edit.
  5. Under Logging, select the following in the Destination field:
    • Not specified: To disable logging.
    • Folder: To write logs to the default log group for the folder containing the API gateway.
      1. (Optional) In the Min. logging level field, select the minimum logging level.
    • Log group: To write logs to a custom log group.
      1. (Optional) In the Min. logging level field, select the minimum logging level.
      2. In the Log group field, select the log group to write the logs to. If you do not have a log group, create one.
  6. Click Save.

If you set the minimum logging level, logs of that level and higher will be written to the execution log. With no minimum logging level set, all API gateway logs will be written to the execution log.

If you do not have the Yandex Cloud (CLI) command line interface yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

Logging destination

If a custom log group is not specified in the API gateway parameters or logging is not turned off, the API gateway automatically writes all logs to the default log group for the folder it resides in.

To write logs to a custom log group, provide the log group ID in the --log-group-id parameter when creating or modifying an API gateway. The log group must reside in the same folder as the API gateway.

Minimum logging level

To set a minimum logging level, provide it in the --min-log-level parameter when creating or modifying an API gateway.

If you set the minimum logging level, logs of that level and higher will be written to the execution log. With no minimum logging level set, all API gateway logs will be written to the execution log.

Disabling logging

To disable logging, set the --no-logging parameter when creating or modifying an API gateway.

Command example

To write logs to a custom log group, run this command:

yc serverless api-gateway update <API_gateway_name_or_ID> \
  --log-group-id <log_group_ID> \
  --min-log-level <minimum_logging_level>

Where:

  • --log-group-id: ID of the log group to write logs to.
  • --min-log-level: Minimum logging level. The available levels are TRACE, DEBUG, INFO, WARN, ERROR, and FATAL. This is an optional parameter.

Result:

id: d5dr8k465604********
folder_id: b1g3f9i71bpm********
created_at: "2024-01-26T09:18:55.985Z"
name: example_gateway
status: ACTIVE
domain: d5dm1lba80md********.i9******.apigw.yandexcloud.net
log_group_id: ckgsh1kdbvj1********
connectivity: {}
log_options:
  log_group_id: e23u2vn449av********
  min_level: ERROR

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the documentation on the Terraform website or mirror website.

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

Logging destination

If a custom log group is not specified in the API gateway parameters or logging is not turned off, the API gateway automatically writes all logs to the default log group for the folder it resides in.

To write logs to a custom log group, under log_options, provide the log group ID in the log_group_id parameter when creating or modifying an API gateway. The log group must reside in the same folder as the API gateway.

Minimum logging level

To set a minimum logging level, provide it in the log_group_id parameter under log_options when creating or modifying an API gateway.

If you set the minimum logging level, logs of that level and higher will be written to the execution log. With no minimum logging level set, all API gateway logs will be written to the execution log.

Disabling logging

To disable logging, under log_options, set the disabled parameter to true when creating or modifying an API gateway.

Example

To write logs to a custom log group:

  1. Open the Terraform configuration file and add the log_options section to the yandex_api_gateway resource description:

    Here is an example of the configuration file structure:

    resource "yandex_api_gateway" "<API_gateway_name>" {
      ...
      log_options {
        folder_id = "<folder_ID>"
        min_level = "<minimum_logging_level>"
      }
      ...
    }
    

    Where:

    • folder_id: Folder ID.
    • min_level: Minimum logging level. The available levels are TRACE, DEBUG, INFO, WARN, ERROR, and FATAL. This is an optional parameter.

    For more information about the yandex_api_gateway resource parameters in Terraform, see the relevant provider documentation.

  2. Check the configuration using this command:

    terraform validate
    

    If the configuration is correct, you will get this message:

    Success! The configuration is valid.
    
  3. Run this command:

    terraform plan
    

    The terminal will display a list of resources with parameters. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.

  4. Apply the configuration changes:

    terraform apply
    
  5. Confirm the changes: type yes into the terminal and press Enter.

To write to the execution log in Yandex API Gateway, use the update REST API method for the ApiGateway resource or the ApiGatewayService/Update gRPC API call.

Was the article helpful?

Previous
Viewing logs
Next
Removing a domain
Yandex project
© 2025 Yandex.Cloud LLC