Using the gelf log driver from compose

Hi,
I’m trying to get the gelf driver to work from inside my compose so that I can push logs toward logstash. If I run a container by hand with docker run, it starts logging to logstash. If I use the same options in my docker-compose.yml, the container starts with: WARNING: no logs are available with the ‘gelf’ driver.

My yaml looks like:

log_driver: gelf
log_opt:
gelf-address:udp://localhost:12201
gelf-tag: thing

So I know that my logstash is listening and that there isn’t anything inherently wrong with docker and gelf. So what am I doing wrong?

thanks!
Carey

1 Like

I am having this same problem. Using version two formatting:

  logging:
    driver: gelf
    options:
      gelf-address: "udp://log.servername.com:514"

Weird thing is it worked yesterday when tested with a simple nginx container. That same container on a different machine did not work today.

Docker version:

Client:
 Version:      1.10.0
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   590d5108
 Built:        Thu Feb  4 18:36:33 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.0
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   590d5108
 Built:        Thu Feb  4 18:36:33 2016
 OS/Arch:      linux/amd64

For those stumbling upon this thread in the future I was having issue with this as well and this gist helped: https://gist.github.com/eunomie/e7a183602b8734c47058d277700fdc2d

Specifically the line:

Careful, the address to send the log is relative to the docker host, not the container!

So I ended up with something like:

  logging:
    driver: gelf
    options:
      gelf-address: "udp://localhost:12201"

I am using same configuration, but instead of udp, it’s tcp and I can’t see exceptions log at Graylog stream, that it get when on container start