Docker Community Forums

Share and learn in the Docker community.

Support dynamic addtional fields in GELF log driver

Currently, Docker does support static additional fields in the GELF log driver through environment variables. I’d like a way to set additional fields each time I log. For example, a field that holds a trace ID or something similar that is specific to that log message, and not the entire application like teamName.

Can anyone confirm that this isn’t currently supported? Any reason it couldn’t be added?

I’m trying to think of ways to support these “per log message” dynamic additional fields without breaking current behavior or having a heavy impact on performance.

Are you sending GELF messages into Graylog within your Docker container? If so, the Graylog GELF format does support custom fields. To supply a custom field, just add an underscore before the field name as shown here. As long as you also supply the required fields (see doc reference below), then the message will be parsed successfully.

Additional GELF field

I’m trying to log to stdout from my application then have docker forward those logs to a GELF endpoint. However the message that is logged to stdout has no way to specify those additional fields beginning with an underscore. Unless I’m misunderstanding you.