Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/v1.14/BUG FIXES-20250814-120000.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: BUG FIXES
body: 'logging: Fixed JSON format being ignored in some logging subsystems when TF_LOG_* environment variables are set to "JSON"'
time: 2025-08-14T12:00:00.000000+00:00
custom:
Issue: "37433"
20 changes: 17 additions & 3 deletions internal/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,26 @@ func globalLogLevel() (hclog.Level, bool) {
if envLevel == "" {
envLevel = strings.ToUpper(os.Getenv(envLogCore))
}
if envLevel == "JSON" {
json = true
}

// Check if JSON formatting is requested by any subsystem
json = isJSONFormatRequested()

return parseLogLevel(envLevel), json
}

// isJSONFormatRequested checks if any logging subsystem has requested JSON formatting
func isJSONFormatRequested() bool {
logEnvVars := []string{envLog, envLogCore, envLogProvider, envLogCloud, envLogStacks}

for _, envVar := range logEnvVars {
if strings.ToUpper(os.Getenv(envVar)) == "JSON" {
return true
}
}

return false
}

func parseLogLevel(envLevel string) hclog.Level {
if envLevel == "" {
return hclog.Off
Expand Down