Whenever we connect to mongo thru shell, we get some logs. I just want the query result not the other logs except the failure message. Is there any way to configure that?
MongoDB shell version v3.6.11
connecting to: mongodb://localhost:27070/test?authMechanism=MONGODB-X509
2020-04-10T21:40:59.305+0000 I NETWORK [thread1] Starting new replica set monitor for
2020-04-10T21:40:59.516+0000 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] SSL peer certificate validation failed: self signed certificate in certificate chain
2020-04-10T21:40:59.519+0000 W NETWORK [thread1] SSL peer certificate validation failed: self signed certificate in certificate chain
2020-04-10T21:40:59.586+0000 I NETWORK [thread1] Successfully connected to localhost:27070 (1 connections now open to localhost:27070 with a 5 second timeout)
2020-04-10T21:40:59.586+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to localhost:27070 (1 connections now open to localhost:27070 with a 5 second timeout)
2020-04-10T21:40:59.653+0000 I NETWORK [thread1] changing hosts to ....
2020-04-10T21:40:59.865+0000 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] SSL peer certificate validation failed: self signed certificate in certificate chain
2020-04-10T21:40:59.868+0000 W NETWORK [thread1] SSL peer certificate validation failed: self signed certificate in certificate chain
2020-04-10T21:40:59.932+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to localhost:27070 (1 connections now open to localhost:27070 with a 5 second timeout)
2020-04-10T21:41:00.007+0000 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Failed to connect to localhost:27070, in(checking socket for error after poll), reason: Connection refused
2020-04-10T21:41:00.019+0000 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] SSL peer certificate validation failed: self signed certificate in certificate chain
2020-04-10T21:41:00.021+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to localhost:27070 (1 connections now open to localhost:27070 with a 5 second timeout)
2020-04-10T21:41:00.032+0000 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] SSL peer certificate validation failed: self signed certificate in certificate chain
2020-04-10T21:41:00.032+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to localhost:27070 (1 connections now open to localhost:27070 with a 5 second timeout)
Implicit session: session { "id" : UUID("0a2c342e-6afe-4d1e-zz98-49110d4a1767") }
MongoDB server version: 3.6.8
2020-04-10T21:41:00.471+0000 E QUERY [thread1] Error: don't know how to show [collections()] :
shellHelper.show@src/mongo/shell/utils.js:997:11
shellHelper@src/mongo/shell/utils.js:750:15
@(shellhelp2):1:1
bye
Best Answer
You can use the
--quiet
option to suppress output including themongo
shell version and startup warnings during the connection process.Those startup warnings are usually issues an administrator would want to be aware of, but you may prefer to suppress them for a development environment or for running scripts. For a production system you would be best addressing the reported issues to remove future startup warnings.
For example, connecting to a 3.6 deployment with a 4.4 shell:
Adding
--quiet
and connecting to the same MongoDB deployment:The warnings being suppressed in this example indicate:
mongo
shell version (v4.4.3) is much newer than my server version (v3.6.17). Mixing these versions may have unexpected outcomes, particularly given so many intervening MongoDB releases. For a local installation I normally expect these versions to be identical, and for production usage I would want the major versions to be matching (i.e. both v4.4.x or v3.6.x).