I am using tmux
as my default terminal.
The following is the terminal log, on entering the command sudo mongod
{"t":{"$date":"2021-01-28T18:10:29.521+05:30"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2021-01-28T18:10:29.523+05:30"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2021-01-28T18:10:29.523+05:30"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2021-01-28T18:10:29.524+05:30"},"s":"I", "c":"STORAGE", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":27636,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"khaldrogo-HP-Notebook"}}
{"t":{"$date":"2021-01-28T18:10:29.524+05:30"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.3","gitVersion":"913d6b62acfbb344dde1b116f4161360acd8fd13","openSSLVersion":"OpenSSL 1.1.1f 31 Mar 2020","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu2004","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2021-01-28T18:10:29.524+05:30"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Ubuntu","version":"20.04"}}}
{"t":{"$date":"2021-01-28T18:10:29.524+05:30"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{}}}
{"t":{"$date":"2021-01-28T18:10:29.547+05:30"},"s":"I", "c":"STORAGE", "id":22270, "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"/data/db","storageEngine":"wiredTiger"}}
{"t":{"$date":"2021-01-28T18:10:29.547+05:30"},"s":"I", "c":"STORAGE", "id":22297, "ctx":"initandlisten","msg":"Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem","tags":["startupWarnings"]}
{"t":{"$date":"2021-01-28T18:10:29.547+05:30"},"s":"I", "c":"STORAGE", "id":22315, "ctx":"initandlisten","msg":"Opening WiredTiger","attr":{"config":"create,cache_size=1413M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress,compact_progress],"}}
...continued
How do I get a proper format of output?
Mongo recommends jq tool.
This filter would generate output similar to the old style:
jq -c '.t["$date"] + " " + .s + " " + .c + " [" + .ctx + "] " + .msg' /var/log/mongo/mongo.log
It might be useful to filter only for warnings and (fatal) errors:
select( .s == "W" or .s =="E" or .s =="F" ) | .t["$date"] + " " + .s + " " + .c + " [" + .ctx + "] " + .msg
"2021-01-28T18:10:29.523+05:30 W ASIO [main] No TransportLayer configured during NetworkInterface startup"
or try this one:
select( .s | contains("W","E","F") ) | .t["$date"] + " -> " + .c + " " + .msg + "\n attr: " + (.attr | tostring) + "\n tags: " + (.tags|tostring)
See jq play