4

We are experiencing huge logs creation in our MongoDB shard setup. Log settings used are default values -

            firstset:PRIMARY> db.getLogComponents()
  {
"verbosity" : 0,
"accessControl" : {
    "verbosity" : -1
},
"command" : {
    "verbosity" : -1
},
"control" : {
    "verbosity" : -1
},
"executor" : {
    "verbosity" : -1
},
"geo" : {
    "verbosity" : -1
},
"index" : {
    "verbosity" : -1
},
"network" : {
    "verbosity" : -1,
    "asio" : {
        "verbosity" : -1
    },
    "bridge" : {
        "verbosity" : -1
    }
},
"query" : {
    "verbosity" : -1
},
"replication" : {
    "verbosity" : -1
},
"sharding" : {
    "verbosity" : -1
},
"storage" : {
    "verbosity" : -1,
    "journal" : {
        "verbosity" : -1
    }
},
"write" : {
    "verbosity" : -1
},
"ftdc" : {
    "verbosity" : -1
}

}

We need only error and warning logs. Reference document (https://docs.mongodb.com/manual/reference/log-messages/) mentions these levels. I need to know how i can change the level.

1
  • Have you found a work around? Level 0 is very verbose and even quiet mode does log too much messages. Commented Dec 20, 2021 at 18:43

1 Answer 1

4

You have the verbosity set to 0 overall and every individual component is set to -1, which means they will all inherit the parent verbosity setting (of 0). That is as low as the verbosity setting goes, to further reduce the logging you can set systemLog.quiet but that is not recommended for production systems because it can make tracking down issues too difficult and it may not address the root cause in any case.

You mention that the reason you are looking into this is the volume of logs you are seeing, so I would suggest the best thing to do would be to figure out what is causing the excessive logging (slow queries? something else?) at the lowest verbosity level and address that.

Note that if it is slow queries (and you are OK with them being that slow) you may just want to adjust the default 100ms operationProfiling.slowOpThresholdMs threshold upward to reduce that logging specifically.

2
  • Mongod instance is started with - /opt/mongodb/bin/mongod --port=27017 --config /opt/mongodb.conf --dbpath=/data/shard/data/ --replSet firstset --maxConns=20000 --logpath=/data/shard/log/mongodb1.log. And Our Config file is - net: http: enabled: true. Where and how Can i set slowOpThresHold value so that is does not use default 100MS? Commented Jul 6, 2016 at 6:25
  • you do it by adding the option to the /opt/mongodb.conf file you mentioned, in fact I recommend putting all your settings (replSet, maxConns, port etc.)in there and not using command line flags. For examples of how to construct the config files see here: dba.stackexchange.com/a/82592/6441 and the link to the specific option documentation is already in the answer
    – Adam C
    Commented Jul 6, 2016 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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