Bitzu

Terraform Associate 004 ยท Maintaining infrastructure

Verbose logging

TF_LOG levels (TRACE to ERROR), TF_LOG_PATH, TF_LOG_CORE and TF_LOG_PROVIDER, when to enable and sensitive data in logs (7c).

Key points

  • Set TF_LOG to TRACE, DEBUG, INFO, WARN or ERROR (most to least verbose) to get detailed logs on stderr; logging is off until TF_LOG is set.
  • TF_LOG_PATH appends the logs to a file, but only together with TF_LOG.
  • TF_LOG_CORE and TF_LOG_PROVIDER switch on core or provider logs separately.
  • Turn it on when diagnosing a problem or filing a bug, and review logs before sharing since they may expose request details.

Source: https://developer.hashicorp.com/terraform/internals/debugging

Practice questions

Single choice

Which TF_LOG level is the most verbose?

  1. TRACE
  2. DEBUG
  3. INFO
  4. ERROR
Show answer

Answer: A. TRACE

TRACE is the most detailed, followed by DEBUG, INFO, WARN and ERROR. DEBUG is tempting but is one step lower.

Select all that apply

Which statements about Terraform logging variables are true?

  1. TF_LOG_CORE enables logs for Terraform core separately
  2. TF_LOG_PROVIDER enables logs for provider plugins separately
  3. TF_LOG_PATH appends logs to a file
  4. Logs go to standard output by default
  5. TF_LOG accepts the level LOUD for maximum detail
Show answer

Answer: A. TF_LOG_CORE enables logs for Terraform core separately, B. TF_LOG_PROVIDER enables logs for provider plugins separately, C. TF_LOG_PATH appends logs to a file

Core, provider and path variables behave as described. Logs go to stderr, and LOUD is not a level.

True or false

Setting only TF_LOG_PATH is enough to turn on logging.

Show answer

Answer: False

False. TF_LOG must be set for any logging; TF_LOG_PATH just chooses the file.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More Terraform Associate 004 topics in this module