问题
Having an issue getting the --log-opt env=env1,env2
option to work with docker 1.12 swarm-mode and graylog. All of my logs are being sent fine and the tag is coming through. However I see nothing coming in at all from the env
setting. I also tried using --log-opt labels=dev
but had the same issue.
They are being shipped to graylog and I'm not seeing it anywhere within any of the log fields that come through. Any ideas on what I'm doing wrong here?
docker service create --log-driver=gelf --log-opt gelf-address=udp://logserver:12201 --log-opt tag="app-name" --log-opt env=dev ...
回答1:
I had the same issue and answered it here: https://stackoverflow.com/a/40182515/701260
When you use --log-opt env=dev
, it will retrieve the variable dev
from environment and include it in the event eg. dev: <val-from-env
.
Labels do the same with docker labels.
来源:https://stackoverflow.com/questions/40030555/docker-gelf-driver-env-option