From 5c0351cc6f1b532cbdd1602736ad3ddac99fec01 Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Fri, 5 Nov 2021 10:12:32 -0700 Subject: Log Apache access_log-like entries at Info level [NO NEW TESTS NEEDED] Only log API access entries when --log-level set to Info or below. Fixes #12181 Signed-off-by: Jhon Honce --- pkg/api/server/handler_rid.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/api/server/handler_rid.go b/pkg/api/server/handler_rid.go index b624b99a6..7dcf436f7 100644 --- a/pkg/api/server/handler_rid.go +++ b/pkg/api/server/handler_rid.go @@ -2,6 +2,7 @@ package server import ( "fmt" + "io/ioutil" "net/http" "github.com/containers/podman/v3/pkg/api/types" @@ -15,7 +16,13 @@ import ( // and Apache style request logging func referenceIDHandler() mux.MiddlewareFunc { return func(h http.Handler) http.Handler { - return handlers.CombinedLoggingHandler(logrus.StandardLogger().Out, + // Only log Apache access_log-like entries at Info level or below + out := ioutil.Discard + if logrus.IsLevelEnabled(logrus.InfoLevel) { + out = logrus.StandardLogger().Out + } + + return handlers.CombinedLoggingHandler(out, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { rid := r.Header.Get("X-Reference-Id") if rid == "" { -- cgit v1.2.3-54-g00ecf