To capture a trace log, set the environment variable
TRACE. With this set,
TRACE level logging will be captured in the output. Here are the steps in more detail per Terraform product:
If this run is in Terraform Cloud (or being run in Terraform Enterprise via the remote backend), peform these steps:
TRACEin the Environment Variables section of your workspace’s Variables page, and
- 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
.logwill 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 2>&1 | tee apply.txt
Windows Operating Systems
At a Powershell prompt, use this example:
$Env:TF_LOG = "TRACE" terraform apply 2>&1 | Tee-Object -FilePath apply.txt
Once the issue is resolved, unset the
TF_LOG environment variable to disable the enhanced logging.