7.2.2. Verbose Logging
💡 First Principle: Terraform's internal decision-making is normally hidden, so when you need to debug a confusing failure you raise the log level via an environment variable — the verbosity is a dial (TF_LOG), not a per-command flag.
Verbose logging is enabled with the TF_LOG environment variable, set to one of TRACE, DEBUG, INFO, WARN, or ERROR — with TRACE being the most detailed:
export TF_LOG=TRACE
export TF_LOG_PATH=./terraform.log # optional: also write logs to a file
terraform apply
TF_LOG_PATH persists logs to a file (useful for sharing with support or reviewing later). You can also target TF_LOG_CORE and TF_LOG_PROVIDER separately to focus on core engine versus provider plugin activity. Logging is for troubleshooting — diagnosing provider errors, unexpected plans, or crashes.
⚠️ Exam Trap: Logging is controlled by environment variables (TF_LOG, TF_LOG_PATH), not a --verbose CLI flag. TRACE is the most verbose level. If an answer proposes a logging flag on the command line, it's wrong for Terraform.
Reflection Question: Why is TF_LOG_PATH valuable when reporting a hard-to-reproduce bug, compared with reading the logs on screen?