0

I have setup 3 replicas on mongodb. I am facing a lot of mongoDb logs in the log file of mongodb, and I want to minimize the logs to show only errors, warning and critical logs but not for connection and access. to which verbosity level I should have to set the logs?

My current setting for logs in config file:

systemLog:
  destination: file
  logAppend: true
  path: /data/log/mongodb/mongod.log
  component:
      accessControl:
         verbosity: 1
      command:
         verbosity: 1
      # COMMENT some component verbosity settings omitted for brevity
      replication:
         verbosity: 1
         election:
            verbosity: 1
         heartbeats:
            verbosity: 1
         initialSync:
            verbosity: 1
         rollback:
            verbosity: 1
      storage:
         verbosity: 1
         journal:
            verbosity: 1
         recovery:
            verbosity: 1
      write:
         verbosity: 1

And one more question, Do logs make any impact on mongoDb performance? e.g. If my mongoDb logs file will goes upto 30GB of size in a day, will it impact on mongodb performance?

James Z
  • 12,209
  • 10
  • 24
  • 44
sahil garg
  • 89
  • 5

1 Answers1

2

Default level is 0, i.e. level 1 will even increase the amount of logs. Remove everything below component to use default logging and increase it only the for the component where you like to get more detailed logs.

First, you may check which component creates the most logs.

for component in ACCESS COMMAND CONTROL ELECTION FTDC GEO INDEX INITSYNC JOURNAL NETWORK QUERY RECOVERY REPL REPL_HB ROLLBACK SHARDING STORAGE TXN WRITE - ; do
   c=$( jq -rcM 'select(.c == "'$component'")' /var/log/mongodb/mongod.log | wc -l )
   echo "$component => $c"
done

I reduced the size of logfiles significantly by setting operationProfiling.slowOpThresholdMs to a higher value. Default threshold for "slow operation" is 100 Milliseconds which is fairly low I would say.

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110