title: Logging from Docker
body: <p>I have a rails app running through docker. I bring up the app with docker-compose (config below). The whole app covers a mysql, redis, rails (including sidekiq workers), nginx (with react frontend) and a rsyslog server, which forwards all logs to Loggly</p>
  
  <p>My problem is realated to the logging part. Logs from all services basically gets forwarded, except from my logs from sidekiq. 
  When I start sidekiq with <code>bundler exec sidekiq</code> the logs are output to the console (stdout), but I dont see them when I tail /var/log/messages on the rsyslog server.</p>
  
  <p>I followed this tutorial when setting up the logging on docker:</p>
  
  <p><a href="https://medium.com/@yoanis_gil/logging-with-docker-part-1-b23ef1443aac" rel="nofollow noreferrer">https://medium.com/@yoanis_gil/logging-with-docker-part-1-b23ef1443aac</a></p>
  
  <p>My thinking is that everything that goes to stdout in a docker container should be logged to the docker log mechanism - and with my setup that means it should go to the syslog server...</p>
  
  <p>The docker-compose file:</p>
  
  <pre><code>version: '3'
  
  services:
    nginx:
      image: nginx
      depends_on:
        - api
        - syslog
      ports:
        - "80:8080"
  
      logging:
        driver: syslog
        options:
          syslog-facility: "daemon"
          tag: "nginx"
          syslog-address: "tcp://localhost:5514"
      networks:
        - phototankswarm
      env_file: .env.dev
      volumes:
        - ./frontend/nginx/conf.d:/etc/nginx/conf.d
        - ./frontend/public:/www
  
    db:
      image: mysql
      env_file: .env.dev
      depends_on:
        - syslog
      networks:
        - phototankswarm
      ports:
        - "3306:3306"
      volumes:
        - ./backend/sql/data:/var/lib/mysql
      logging:
        driver: syslog
        options:
          syslog-facility: "daemon"
          tag: "mysql"
          syslog-address: "tcp://localhost:5514"
  
    redis:
      image: redis
      depends_on:
        - syslog
      networks:
        - phototankswarm
      logging:
        driver: syslog
        options:
          syslog-facility: "daemon"
          tag: "redis"
          syslog-address: "tcp://localhost:5514"
  
    api:
      image: pt-rails
      env_file: .env.dev
      networks:
        - phototankswarm
      command: &gt;
        sh -c '
        rails s -p 3000 -b 0.0.0.0;
        '
      volumes:
        - /Users/martinhinge/Pictures/docker/phototank:/media/phototank
        - ./backend:/usr/src/app
      ports:
        - "3000:3000"
      depends_on:
        - db
        - redis
        - syslog
      logging:
        driver: syslog
        options:
          syslog-facility: "daemon"
          tag: "rails"
          syslog-address: "tcp://localhost:5514"
  
    syslog:
      image: syslog
      ports:
        - "localhost:5514:514"
      networks:
        - phototankswarm
      volumes:
        - /tmp:/var/log/syslog
  
  networks:
    phototankswarm:
  </code></pre>