Skip to content

Commit

Permalink
Log Apache access_log-like entries at Info level [NO NEW TESTS NEEDED]
Browse files Browse the repository at this point in the history
Only log API access entries when --log-level set to Info or below.

Fixes #12181

Signed-off-by: Jhon Honce <[email protected]>
  • Loading branch information
jwhonce committed Nov 5, 2021
1 parent 9b3b449 commit 5c0351c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/api/server/handler_rid.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"fmt"
"io/ioutil"
"net/http"

"github.com/containers/podman/v3/pkg/api/types"
Expand All @@ -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 == "" {
Expand Down

0 comments on commit 5c0351c

Please sign in to comment.