Skip to main content
In this guide, you’ll learn how to enable and use debugging in Terraform to troubleshoot issues. When errors occur during Terraform operations, the logs offer invaluable insight into the underlying problems. Although running terraform apply usually points out error sources during provisioning, there are instances when you need more detailed internal logs. Terraform’s TF_LOG environment variable allows you to access these detailed logs. Terraform supports various log levels: info, warning, error, debug, and trace—with trace providing the most verbose output. By setting TF_LOG to one of these levels, Terraform outputs additional details during command execution. For example, running a Terraform plan with TF_LOG set to trace may produce hundreds or even thousands of log entries, including low-level details from Terraform plugins. Such detailed logs are particularly useful for diagnosing issues within Terraform or when submitting a bug report. Below is an example output from running terraform plan with detailed logging enabled:
To persist the logs to a file rather than outputting them only to the console, use the TF_LOG_PATH environment variable. The example below demonstrates setting the log path so that all generated logs are recorded in the specified file:
After running your Terraform command, you can inspect the log file. For instance:
To disable logging, simply unset the TF_LOG and TF_LOG_PATH environment variables. This stops Terraform from generating extensive log output.
That concludes this article on Terraform logging. To verify your understanding, please proceed to the multiple-choice quiz for this section.

Watch Video