문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top