Terraform CLI Cheat Sheet/Write Terraform log to file

Persist Terraform debug logs to a file.

Section: Variables and Environment

Write Terraform log to file

bash
bash
export TF_LOG_PATH=./terraform.log
Explanation

Persist Terraform debug logs to a file.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Variables and Environment
Enable Terraform logging
Turn on Terraform internal logging for troubleshooting.
OpenIn sheetbashsame section
Set TF_VAR variable
Pass an input variable through environment variables.
OpenIn sheetbashsame section
Default extra CLI args
Inject default arguments for a specific Terraform subcommand.
OpenIn sheetbashsame section
Change .terraform directory
Store provider/plugins and local data in a custom directory.
OpenIn sheetbashsame section
Disable interactive input
Fail instead of prompting for missing variables.
OpenIn sheetbashsame section
Show Terraform version
Print the installed Terraform CLI version and provider versions in use.
OpenIn sheetbash1 tag match