Skip to main content
When provisioning resources with OpenTofu, failures and unexpected errors often require deeper inspection. Enabling debug logging surfaces internal details and helps you troubleshoot more effectively. In this guide, you’ll learn how to:
  • Configure log verbosity with TF_LOG
  • Persist logs to disk using TF_LOG_PATH
  • Disable verbose logging when you’re done

1. Configure Log Verbosity

OpenTofu honors the standard Terraform log levels via the TF_LOG environment variable. You can choose from five levels:
Setting TF_LOG=TRACE produces the most comprehensive output, including plugin operations, HTTP requests, and configuration decisions.
To enable debugging, export the desired level:
Now, any OpenTofu command will include detailed log entries. For example:
Log levels below TRACE can sometimes omit critical details. If you’re troubleshooting core OpenTofu behavior, always default to TF_LOG=TRACE.

2. Persisting Logs to a File

For lengthy runs or CI environments, capture logs into a file by setting TF_LOG_PATH. All output from TF_LOG will be written to the specified path:
You can verify the beginning of the log file with:
Example output:

3. Disabling Debug Logging

Once you’ve finished troubleshooting, remove the logging environment variables to return to standard output:

See Also

Watch Video