Repository: caddyserver/caddy (language: go)

Issue:
Consider using zap's `RedirectStdLog`
See https://pkg.go.dev/go.uber.org/zap#RedirectStdLog

This should let us catch some of the remaining logs messages that are currently being `log.Printf`'d by some dependencies (such as in https://github.com/caddyserver/certmagic/blob/03cffeb193e09e08a947141e572845fa254089c4/maintain.go#L526).


Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index 5322a53f0d8..e154526b3a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
 _gitignore/
 *.log
 Caddyfile
+Caddyfile.*
 !caddyfile/
 
 # artifacts from pprof tooling
diff --git a/logging.go b/logging.go
index 129aec4301f..5f8ea06a908 100644
--- a/logging.go
+++ b/logging.go
@@ -661,9 +661,15 @@ func newDefaultProductionLog() (*defaultCustomLog, error) {
 
 	cl.buildCore()
 
+	logger := zap.New(cl.core)
+
+	// capture logs from other libraries which
+	// may not be using zap logging directly
+	_ = zap.RedirectStdLog(logger)
+
 	return &defaultCustomLog{
 		CustomLog: cl,
-		logger:    zap.New(cl.core),
+		logger:    logger,
 	}, nil
 }
 


Test patch: