I have to forward my logs to rsyslog via UDP, but due to the volatile nature of UDP and rsyslog I would like to also log to a file. However, AFAICT MongoDB only allows one target for its logs:
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
#destination: syslog
I'm using the latest mongodb 4.
Unless I'm mistaken it doesn't even support remote syslog: https://docs.mongodb.com/manual/reference/configuration-options/#systemLog.destination
How can I log to something file-alike and a remote syslog using mongodb?
Best Answer
I found a solution where i configure rsyslog to pick up that file and forward it to my target server.
Based on: https://www.rsyslog.com/sending-messages-to-a-remote-syslog-server/ and https://serverfault.com/questions/396136/how-to-forward-specific-log-file-outside-of-var-log-with-rsyslog-to-remote-serv