TF-Associate-004 - Maintain infrastructure with Terraform - Section 7c

Describe when and how to use verbose logging.

The TF_LOG environment variable enables verbose logs at levels such as TRACE and DEBUG, and TF_LOG_PATH writes them to a file, for diagnosing provider and core behaviour. Candidates should know logging is controlled by environment variables, not a configuration argument.

TF_LOG environment variablelog levels TRACE and DEBUGTF_LOG_PATHenvironment-variable controlled logging

Practice question for this objective

Free sampleMaintain infrastructure with Terraformeasy

A practitioner is chasing an intermittent provider error during 'terraform apply' and wants Terraform to emit its most detailed internal logging to the terminal for the next run. Which environment variable and value should they set before running the command?

$ export TF_LOG=???
$ terraform apply
  • ASet TF_LOG=VERBOSE, which is the dedicated maximum logging level for provider troubleshooting.
  • BSet TF_LOG=TRACE, which enables the most verbose level and includes all lower levels of detail. Correct
  • CSet TF_LOG=INFO, which prints diagnostic messages while keeping the output readable.
  • DSet TF_DEBUG=1, which switches Terraform into a general debugging mode.
Verbose Terraform logging is controlled by the TF_LOG environment variable, with TRACE giving the most detailed output. Terraform reads its logging verbosity from the TF_LOG environment variable, and TRACE is the most detailed level, capturing all messages that lower levels such as DEBUG or INFO would produce.

Why A is wrong: VERBOSE sounds like the obvious name for maximum logging, but it is not a valid Terraform log level, so the setting would be ignored.

Why B is correct: TRACE is the highest-verbosity log level, so it captures everything the lower levels would and gives the fullest picture of the internal calls behind an intermittent error.

Why C is wrong: INFO is a real level but sits well below TRACE, so it omits much of the low-level detail needed to diagnose an intermittent provider fault.

Why D is wrong: TF_DEBUG looks like a conventional debug switch, but Terraform reads verbosity from TF_LOG, not TF_DEBUG, so this has no effect.

See more TF-Associate-004 practice questions, answers explained.

More in this domain

Back to all Maintain infrastructure with Terraform objectives, or the TF-Associate-004 cert hub.

Examworthy is not affiliated with or endorsed by HashiCorp. Original, blueprint-aligned practice material only.