I am trying to forward MongoDB logs from several remote servers to a central logging server. To do this, I changed my mongod.conf files to use syslog like so:

  destination: syslog
  syslogFacility: local3

I then configured rsyslog to forward messages like so:

if($syslogFacility-text == "local3") then{
  if($syslogTag contains "mongod") then{
    action(type="omfwd" target="MY.SYSLOG.SERVER.IP" port="PORT" protocol="udp")

My logging server is configured to write any messages sent at that port to my central mongod.log file.

My question is; is there a better way to do this? For example, could I specify my logging server's IP/PORT in mongod.conf so I don't have to rely on each Mongo server's local rsyslog?

  1. Mount a drive from central logging server to the MongoDB server.

  2. Update the MongoDB configuration file to redirect the logs to that mounted drive.

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.