winstonjs / winston-syslog

A syslog transport for winston
http://github.com/winstonjs/winston-syslog
MIT License
138 stars 119 forks source link

No logs when running in docker container #171

Closed linus-komnick closed 2 years ago

linus-komnick commented 2 years ago

Everything works fine when I run $ node server.js. But as soon as I run it with docker, my syslog daemon stops receiving any logs.

This is how I implement it: logger.add(new logger.transports.Syslog()); My guess is that I have to add /dev/log as a volume when running docker, but it doesn't seem to work.

Does anybody know how to fix this?

linus-komnick commented 2 years ago

I was missing a couple of steps to make it work. Here is how I solved it:

  1. Uncomment the following in /etc/rsyslog.conf:

    # provides TCP syslog reception
    module(load="imtcp")
    input(type="imtcp" port="514")
  2. Restart syslog:

    systemctl restart rsyslog.service
  3. Create daemon.json in /etc/docker (if it doesn't already exist) and make sure it contains the following:

    {
    "log-driver": "syslog",
    "log-opts": {
    "syslog-address": "tcp://127.0.0.1:514"
    }
    }
  4. Restart docker:

    systemctl restart docker

Now all logs will end up in /var/log/syslog