Domain 7 of 8 · Chapter 3 of 3

Use verbose logging

Unlock the complete study guide + 1,040 practice questions across 16 full exams.

Bundled into the existing HashiCorp Certified: Terraform Associate premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • Turning on Terraform's logs
  • Scoping logs to core, providers, or JSON
  • Persisting logs and reading a crash
  • Exam-pattern recognition

The TF_LOG* environment variable family

AspectTF_LOGTF_LOG_CORE / TF_LOG_PROVIDERTF_LOG_PATH
ControlsAll logs (Core and providers)Core-only or provider-only logsWhere logs are written
AcceptsTRACE..ERROR, JSON, or any valueTRACE..ERRORA file path
Enables logging on its own?YesYes, for its subsetNo, needs a TF_LOG* level too
Output destinationstderrstderrAppended to the named file

Cheat sheet

  • TF_LOG enables logs on stderr
  • TRACE is the most verbose level
  • TF_LOG=JSON emits JSON logs
  • Separate core and provider logging
  • Core and provider vars share the same levels
  • TF_LOG_PATH still needs TF_LOG set
  • When to use verbose logging
  • A crash prints a stack trace to stderr

Unlock with Premium — includes all practice exams and the complete study guide.

References

  1. Debugging Terraform: TF_LOG, TF_LOG_CORE, TF_LOG_PROVIDER, and TF_LOG_PATH
  2. Troubleshoot Terraform (use TF_LOG=TRACE for bug reports)