TA-002-P · Question #198
You have already set TF_LOG = DEBUG to enable debug log. Now you want to always write the log to the directory you're currently running terraform from. what should you do to achieve this.
The correct answer is B. Run the command export TF_LOG_PATH=./terraform.log. TF_LOG_PATH is the correct environment variable to specify the file path where Terraform debug logs are written.
Question
You have already set TF_LOG = DEBUG to enable debug log. Now you want to always write the log to the directory you're currently running terraform from. what should you do to achieve this.
Options
- ARun the command export TF_LOG_FILE=./terraform.log.
- BRun the command export TF_LOG_PATH=./terraform.log.
- CRun the command export TF_DEBUG_PATH=./terraform.log.
- DNo explicit action required. Terraform will take care of this as you have enable TF_LOG.
How the community answered
(25 responses)- A4% (1)
- B88% (22)
- D8% (2)
Why each option
`TF_LOG_PATH` is the correct environment variable to specify the file path where Terraform debug logs are written.
`TF_LOG_FILE` is not a recognized Terraform environment variable; using it will have no effect on log output.
Terraform uses `TF_LOG_PATH` to redirect log output from stderr to a specified file path. Setting `TF_LOG_PATH=./terraform.log` writes logs to `terraform.log` in the current working directory. Without this variable, logs only appear on stderr even when `TF_LOG` is set.
`TF_DEBUG_PATH` is not a valid Terraform environment variable and will not redirect any log output.
Setting `TF_LOG` alone only enables logging to stderr; a separate `TF_LOG_PATH` variable is required to persist logs to a file.
Concept tested: Terraform debug logging with TF_LOG_PATH
Source: https://developer.hashicorp.com/terraform/internals/debugging
Topics
Community Discussion
No community discussion yet for this question.