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:Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
- 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 theTF_LOG environment variable. You can choose from five levels:
| Level | Description |
|---|---|
| ERROR | Only error messages |
| WARN | Warnings and errors |
| INFO | High-level informational messages |
| DEBUG | Detailed execution and decision points |
| TRACE | Full internal trace (most verbose) |
Setting
TF_LOG=TRACE produces the most comprehensive output, including plugin operations, HTTP requests, and configuration decisions.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 settingTF_LOG_PATH. All output from TF_LOG will be written to the specified path: