From 5c6b913ff1e520cae320913bfee43ec86583b666 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich <Jonas@JonasHeinrich.com> Date: Thu, 21 Nov 2019 06:21:42 -0800 Subject: [PATCH] logger/gelf: Skip empty lines to comply with spec The [gelf payload specification](http://docs.graylog.org/en/2.4/pages/gelf.html#gelf-payload-specification) demands that the field `short_message` *MUST* be set by the client library. Since docker logging via the gelf driver sends messages line by line, it can happen that messages with an empty `short_message` are passed on. This causes strict downstream processors (like graylog) to raise an exception. The logger now skips messages with an empty line. Resolves: #40232 See also: #37572 Signed-off-by: Jonas Heinrich <Jonas@JonasHeinrich.com> --- daemon/logger/gelf/gelf.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/daemon/logger/gelf/gelf.go b/daemon/logger/gelf/gelf.go index ab1393cedc..5492e5a4ce 100644 --- a/daemon/logger/gelf/gelf.go +++ b/daemon/logger/gelf/gelf.go @@ -166,6 +166,10 @@ func newGELFUDPWriter(address string, info logger.Info) (gelf.Writer, error) { } func (s *gelfLogger) Log(msg *logger.Message) error { + if len(msg.Line) == 0 { + return nil + } + level := gelf.LOG_INFO if msg.Source == "stderr" { level = gelf.LOG_ERR