You have written a terraform IaC script which was working till yesterday, but is giving some vague error from today, which you are unable to understand. You want more detailed logs that could potentially help you troubleshoot the issue, and understand the root cause.
What can you do to enable this setting? Please note, you are using terraform OSS.
A. Terraform OSS can push all its logs to a syslog endpoint. As such, you have to set up the syslog sink, and enable TF_LOG_PATH env variable to the syslog endpoint and all logs will automatically start streaming.
B. Detailed logs are not available in terraform OSS, except the crash message. You need to upgrade to terraform enterprise for this point.
C. Enable the TF_LOG_PATH to the log sink file location, and logging output will automatically be stored there.
D. Enable TF_LOG to the log level DEBUG, and then set TF_LOG_PATH to the log sink file location. Terraform debug logs will be dumped to the sink path, even in terraform OS
Explanation:
Terraform has detailed logs which can be enabled by setting the TF_LOG environment variable to any value. This will cause detailed logs to appear on stderr.
You can set TF_LOG to one of the log levels TRACE, DEBUG, INFO, WARN or ERROR to change the verbosity of the logs. TRACE is the most verbose and it is the default if TF_LOG is set to something other than a log level name.
To persist logged output you can set TF_LOG_PATH in order to force the log to always be appended to a specific file when logging is enabled. Note that even when TF_LOG_PATH is set, TF_LOG must be set in order for any logging to be enabled.