diff --git a/pkg/config/log.go b/pkg/config/log.go index 2dc33fdfbbbbb..803a798b3d576 100644 --- a/pkg/config/log.go +++ b/pkg/config/log.go @@ -107,7 +107,7 @@ func SetupLogger(logLevel, logFile, uri string, rfc, logToConsole, jsonFormat bo configTemplate += fmt.Sprintf(` - + @@ -304,7 +304,14 @@ func (s *SyslogReceiver) Close() error { return nil } +func createQuoteMsgFormatter(params string) seelog.FormatterFunc { + return func(message string, level seelog.LogLevel, context seelog.LogContextInterface) interface{} { + return strconv.Quote(message) + } +} + func init() { + seelog.RegisterCustomFormatter("QuoteMsg", createQuoteMsgFormatter) seelog.RegisterCustomFormatter("CustomSyslogHeader", createSyslogHeaderFormatter) seelog.RegisterReceiver("syslog", &SyslogReceiver{}) } diff --git a/releasenotes/notes/fix-invalid-json-f5a3e8b4f8ee75e5.yaml b/releasenotes/notes/fix-invalid-json-f5a3e8b4f8ee75e5.yaml new file mode 100644 index 0000000000000..5472a0e9ddcb7 --- /dev/null +++ b/releasenotes/notes/fix-invalid-json-f5a3e8b4f8ee75e5.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Fix invalid JSON in log