I see FieldKeyMsg is set here... https://github.com/sirupsen/logrus/blob/master/formatter.go#L8 ...to msg, and I would like it to be set to message but as it's a constant I'm not able to change it and I'm not sure the 'custom formatter' feature allows for changing it either.
Thanks for any guidance you can give me.
The reason I ask is because I'm using Datadog and they require the logged field to be message.
you can use the FieldMap configuration of the JSONFormatter to specify how to name the FieldKeyMsg. You can look at the documentation of the JSONFormatter to see an example.
Something like that should work:
formatter := &logrus.JSONFormatter{
FieldMap: logrus.FieldMap{
FieldKeyMsg: "message",
}
},
logrus.SetFormatter(formatter)
Perfect! Thanks @dgsb
Most helpful comment
Something like that should work: