summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Goff <cpuguy83@gmail.com>2023-03-21 17:45:14 +0000
committerSebastiaan van Stijn <github@gone.nl>2023-04-21 12:33:33 +0200
commit8a6bec6e164d4eb47578d37b84e7b8379e158545 (patch)
treee84bdaf4fa2ef05c84798b7de0584d7efee5b432
parent8fdca288c5c9d84dc27ed65b4e67c885452e27e9 (diff)
downloaddocker-8a6bec6e164d4eb47578d37b84e7b8379e158545.tar.gz
Silence GRPC logs unless our log level is debug
GRPC is logging a *lot* of garbage at info level. This configures the GRPC logger such that it is only giving us logs when at debug level and also adds a log field indicating where the logs are coming from. containerd is still currently spewing these same log messages and needs a separate update. Without this change `docker build` is extremely noisy in the daemon logs. Signed-off-by: Brian Goff <cpuguy83@gmail.com> (cherry picked from commit c7ccc68b15fc0fc8c2a8683170e6d61e3381e358) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
-rw-r--r--cmd/dockerd/docker.go1
-rw-r--r--cmd/dockerd/grpclog.go17
2 files changed, 18 insertions, 0 deletions
diff --git a/cmd/dockerd/docker.go b/cmd/dockerd/docker.go
index f56be8fd70..8082c2fbaf 100644
--- a/cmd/dockerd/docker.go
+++ b/cmd/dockerd/docker.go
@@ -88,6 +88,7 @@ func main() {
_, stdout, stderr := term.StdStreams()
initLogging(stdout, stderr)
+ configureGRPCLog()
onError := func(err error) {
fmt.Fprintf(stderr, "%s\n", err)
diff --git a/cmd/dockerd/grpclog.go b/cmd/dockerd/grpclog.go
new file mode 100644
index 0000000000..2d726c7f76
--- /dev/null
+++ b/cmd/dockerd/grpclog.go
@@ -0,0 +1,17 @@
+package main
+
+import (
+ "github.com/sirupsen/logrus"
+ "google.golang.org/grpc/grpclog"
+)
+
+// grpc's default logger is *very* noisy and uses "info" and even "warn" level logging for mostly useless messages.
+// This function configures the grpc logger to step down the severity of all messages.
+//
+// info => trace
+// warn => debug
+// error => warn
+func configureGRPCLog() {
+ l := logrus.WithField("library", "grpc")
+ grpclog.SetLoggerV2(grpclog.NewLoggerV2(l.WriterLevel(logrus.TraceLevel), l.WriterLevel(logrus.DebugLevel), l.WriterLevel(logrus.WarnLevel)))
+}