0

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?

0

I found a solution where i configure rsyslog to pick up that file and forward it to my target server.

# RSyslog Configuration for MongoDB /etc/rsyslog.d/mongod.conf
$ModLoad imfile
$InputFileName /var/log/mongodb/mongod.log
$InputFileTag mongodb
$InputFileStateFile mongodb-state
$InputFileFacility local3
$InputRunFileMonitor
local3.* action(type="omfwd" target="target" port="514" protocol="udp" action.resumeRetryCount="100" queue.type="linkedList" queue.size="10000")

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.