Junior — Middle
How are logs maintained in Terraform and how do they assist in infrastructure management?
sobes.tech AI
Answer from AI
Terraform logs are managed through the environment variable TF_LOG, which allows enabling different levels of logging: TRACE, DEBUG, INFO, WARN, ERROR. Logs help track the execution process of Terraform commands, identify errors, and understand what changes are happening in the infrastructure. For example, during debugging complex configurations, you can set TF_LOG=DEBUG to get detailed information about provider steps and internal operations.
Example of enabling logs in Linux/macOS:
export TF_LOG=DEBUG
terraform apply
Logs assist in managing infrastructure by providing transparency and auditability of changes, which is especially important in team environments and automation.