Skip to main content
This guide shows how to enable Terraform logging to get detailed diagnostic output when your configuration or provider interactions behave unexpectedly. Use these logs to inspect Terraform core activity (graph transforms, diff processing, provider RPCs) and to gather information you can share with maintainers after scrubbing secrets. Below is a minimal Terraform configuration used for this demo. The specific resources aren’t important for logging; the example simply provides context for the terraform plan output.

Run a normal plan

Start with the default, concise behavior to compare outputs:
Typical (truncated) summary output:

Enable Terraform logging

Terraform supports the following log levels: TRACE, DEBUG, INFO, WARN, and ERROR. TRACE is the most verbose and is useful when you need deep internals. Use TF_LOG to set the log level and TF_LOG_PATH to write logs to a file. Examples below show platform-specific commands.

macOS / Linux (bash or zsh)

Enable trace logging for the current shell:
Run the plan again to see detailed trace output:
You will still see the normal plan summary at the end, but the command will include many trace lines showing Terraform core activity, provider registry interactions, graph transforms, diff processing, and provider RPC calls. Example (truncated):
To capture logs to a file (recommended if you will share logs or review them later), set TF_LOG_PATH:

Windows PowerShell

Enable TRACE logging in PowerShell:

Windows CMD

Set environment variables in CMD:

Stop logging

When finished debugging, unset TF_LOG (and TF_LOG_PATH if set) to return to normal concise output. On macOS / Linux:

Log level reference

Use the appropriate log level to control verbosity and reduce noise:

Tips for sharing logs

Avoid sharing logs that may contain secrets, credentials, or sensitive identifiers. Use TF_LOG_PATH to generate a log file you can inspect and sanitize before sharing. If you must send logs to HashiCorp or a provider support team, scrub or redact secrets first.

When to use each level

  • ERROR / WARN — Good for routine runs to identify failures and warnings.
  • INFO — Useful for understanding higher-level operations without too much noise.
  • DEBUG — For investigating implementation-level behavior in Terraform or providers.
  • TRACE — For the deepest visibility into Terraform core, provider RPCs, graph transforms, and diff internals. Reserve for difficult-to-diagnose issues.

Summary

Using TF_LOG and TF_LOG_PATH helps you inspect Terraform internals (graph transforms, provider communications, validations, diffs) and can provide the necessary detail to debug complex provider or core issues. Always review and redact any sensitive data before sharing logs externally.

Watch Video