To capture a trace log, set the environment variable TF_LOG
to TRACE
. With this set, TRACE
level logging will be captured in the output. Here are the steps in more detail per Terraform product:
Terraform Cloud/Enterprise
If this run is in Terraform Cloud or Terraform Enterprise with Remote Execution, perform these steps:
- in the Workspace Settings > General tab, set the User Interface setting to "Console UI"
- set
TF_LOG
toTRACE
in the Environment Variables section of your Workspace’s Variables page - perform the run that failed again
- (Optional) Download the streamed log for further examination in your favorite code editor. You can find the download button towards the top of the failed run.
TIP: Changing the extension of the log from.txt
to .log
will enable colored syntax highlighting for most code editors - which can make it easier to read.
Unix/Linux & MacOS Operating Systems
At the Linux console this method can be used, being sure to capture both stderr and stdout:
export TF_LOG=TRACE
terraform apply -no-color 2>&1 | tee apply.txt
Windows Operating Systems
At a PowerShell prompt, use this example:
$Env:TF_LOG = "TRACE"
terraform apply -no-color 2>&1 | Tee-Object -FilePath apply.txt
Once the issue is resolved, unset the TF_LOG
environment variable to disable the enhanced logging.