Plain language
Terraform normally prints only results and errors. Detailed logs can help when you need to:
- Diagnose provider or API errors and authentication failures
- See which API calls a provider makes
- Investigate unexpected plan behavior
- Attach logs to a bug report
Environment variables
| Variable | Purpose |
|---|---|
TF_LOG |
Turns logging on and sets the level: TRACE (most verbose), DEBUG, INFO, WARN, ERROR. JSON produces TRACE-level output in machine-parseable JSON. |
TF_LOG_PATH |
Writes logs to this file instead of stderr. Logging must also be enabled with TF_LOG, TF_LOG_CORE, or TF_LOG_PROVIDER. |
TF_LOG_CORE |
Sets the level for Terraform core only |
TF_LOG_PROVIDER |
Sets the level for providers only |
TF_LOG=DEBUG terraform plan # to stderr
TF_LOG=TRACE TF_LOG_PATH=./trace.log terraform apply # to a file
TF_LOG_PROVIDER=TRACE TF_LOG_PATH=./prov.log terraform plan # provider calls onlyUnder the hood
- Logs go to stderr, so they don't mix with normal stdout output. That's why
2>captures them. - If Terraform itself panics, it writes a
crash.log. Include it in a GitHub issue for Terraform core. - Logs can contain sensitive data, including request bodies, tokens, and attribute values. Scrub them before sharing.
- Unset the variables when you're done. Verbose logging slows runs and produces very large files.