Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit cdd97d5

Browse files
Jonas-HeinrichthaJeztah
authored andcommitted
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> (cherry picked from commit 5c6b913ff1e520cae320913bfee43ec86583b666) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 449b60fcd06b3ef6235d7b7f4c220889f02a85b2 Component: engine
1 parent 78173b2 commit cdd97d5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • components/engine/daemon/logger/gelf

components/engine/daemon/logger/gelf/gelf.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ func newGELFUDPWriter(address string, info logger.Info) (gelf.Writer, error) {
166166
}
167167

168168
func (s *gelfLogger) Log(msg *logger.Message) error {
169+
if len(msg.Line) == 0 {
170+
return nil
171+
}
172+
169173
level := gelf.LOG_INFO
170174
if msg.Source == "stderr" {
171175
level = gelf.LOG_ERR

0 commit comments

Comments
 (0)