From b1c3649eac7b5f6ca1ab0817c7f22eb8c7fe2403 Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Tue, 18 Oct 2016 13:08:23 -0700 Subject: [PATCH 1/2] Append to debug log files, don't clobber. --- helper/logging/logging.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helper/logging/logging.go b/helper/logging/logging.go index 969a6f151..433cd77d3 100644 --- a/helper/logging/logging.go +++ b/helper/logging/logging.go @@ -6,6 +6,7 @@ import ( "log" "os" "strings" + "syscall" "github.com/hashicorp/logutils" ) @@ -31,7 +32,7 @@ func LogOutput() (logOutput io.Writer, err error) { logOutput = os.Stderr if logPath := os.Getenv(EnvLogFile); logPath != "" { var err error - logOutput, err = os.Create(logPath) + logOutput, err = os.OpenFile(logPath, syscall.O_CREAT|syscall.O_RDWR|syscall.O_APPEND, 0666) if err != nil { return nil, err } From 5bd97d64faad1d4c0750571057dc01d261dc3a70 Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Tue, 18 Oct 2016 13:10:15 -0700 Subject: [PATCH 2/2] Update the docs to indicate that `TF_LOG_PLAN` is append now. --- website/source/docs/internals/debugging.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/source/docs/internals/debugging.html.md b/website/source/docs/internals/debugging.html.md index b5fe73b6b..f6ea583c4 100644 --- a/website/source/docs/internals/debugging.html.md +++ b/website/source/docs/internals/debugging.html.md @@ -12,7 +12,7 @@ Terraform has detailed logs which can be enabled by setting the `TF_LOG` environ 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 go 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. +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. If you find a bug with Terraform, please include the detailed log by using a service such as gist.