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
Which TF_LOG level is the most verbose?
- TRACE
- DEBUG
- INFO
- 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.
Which statements about Terraform logging variables are true?
- TF_LOG_CORE enables logs for Terraform core separately
- TF_LOG_PROVIDER enables logs for provider plugins separately
- TF_LOG_PATH appends logs to a file
- Logs go to standard output by default
- 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.
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.
