Verbose Logging and its Outcome
Learn when to enable verbose logging and its outcomes.
We'll cover the following
Terraform can generate detailed logs by setting the environment variable TF_LOG
to a particular level of verbosity.
Log levels
There are five log levels. From most verbose to least, they are TRACE
, DEBUG
, INFO
, WARN
, and ERROR
. The logs’ output is sent to stderr
. If the TF_LOG
variable is set to anything other than one of the listed log levels (like TF_LOG=HAMSTER
), Terraform will set the log verbosity to TRACE
.
If we want to write the resulting logs to a file location, we can set the environment variable TF_LOG_PATH
to the full path of the desired file location—for example, /var/logs/terraform/my_- log.log
.
What happens when Terraform crashes?
In addition to logs being sent to stderr, Terraform will also generate a log file if the executable
crashes. The log file contains the debug logs, panic message, and backtrace saved to the crash.log
file.
Get hands-on with 1400+ tech skills courses.