From b7d802bbccdf7ec6e4cc1ead733663cdce9768c0 Mon Sep 17 00:00:00 2001 From: Mark Parker Date: Thu, 2 Feb 2017 15:16:14 -0700 Subject: [PATCH] Add NILVALUE for STRUCTURED-DATA in RFC5424 logs RFC 5424 (https://tools.ietf.org/html/rfc5424#section-6.2) requires that STRUCTURED-DATA be present, either as NILVALUE (-) or as one or more SD-ELEMENT items. Because Docker doesn't ever create any SD-ELEMENT items, the format should output the NILVALUE instead. This resolves parsing issues in various RFC 5424-compliant syslog servers. Signed-off-by: Mark Parker --- daemon/logger/syslog/syslog.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/logger/syslog/syslog.go b/daemon/logger/syslog/syslog.go index 1272b8a647..568f1aca50 100644 --- a/daemon/logger/syslog/syslog.go +++ b/daemon/logger/syslog/syslog.go @@ -68,7 +68,7 @@ func init() { func rfc5424formatterWithAppNameAsTag(p syslog.Priority, hostname, tag, content string) string { timestamp := time.Now().Format(time.RFC3339) pid := os.Getpid() - msg := fmt.Sprintf("<%d>%d %s %s %s %d %s %s", + msg := fmt.Sprintf("<%d>%d %s %s %s %d %s - %s", p, 1, timestamp, hostname, tag, pid, tag, content) return msg } @@ -79,7 +79,7 @@ func rfc5424formatterWithAppNameAsTag(p syslog.Priority, hostname, tag, content func rfc5424microformatterWithAppNameAsTag(p syslog.Priority, hostname, tag, content string) string { timestamp := time.Now().Format("2006-01-02T15:04:05.999999Z07:00") pid := os.Getpid() - msg := fmt.Sprintf("<%d>%d %s %s %s %d %s %s", + msg := fmt.Sprintf("<%d>%d %s %s %s %d %s - %s", p, 1, timestamp, hostname, tag, pid, tag, content) return msg }