天天看點

MongoDB4.4新特性-采用全新的JSON格式的日志

從4.4版本開始,MongoDB的​

​mongo​

​​和​

​mongos​

​日志檔案格式采用了JSON格式,更容易分析、解析。在此之前和其他日志檔案格式一樣,純文字輸出。

4.4日志格式

JSON格式更清晰,也更細分析、解析,非常友善。

{"t":{"$date":"2020-08-31T16:23:50.984+08:00"},"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":"2020-08-31T16:23:50.987+08:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-08-31T16:23:50.987+08:00"},"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":"2020-08-31T16:23:50.988+08:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":5836,"port":27017,"dbPath"
:"/usr/local/mongo4.4.0/data/db","architecture":"64-bit","host":"lei"}}
{"t":{"$date":"2020-08-31T16:23:50.988+08:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.0","gitVer
sion":"563487e100c4215e2dce98d0af2a6a5a2d67c5cf","openSSLVersion":"OpenSSL 1.0.1e-fips 11 Feb 2013","modules":[],"allocator":"tcmalloc","environment":{"distmod":"rhel70","dis
tarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-08-31T16:23:50.988+08:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"CentOS Linux relea
se 7.5.1804 (Core) ","version":"Kernel 3.10.0-862.el7.x86_64"}}}
{"t":{"$date":"2020-08-31T16:23:50.988+08:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"
/etc/mongo.conf","net":{"bindIp":"0.0.0.0","maxIncomingConnections":100,"port":27017},"processManagement":{"fork":true},"security":{"authorization":"enabled"},"storage":{"dbP
ath":"/usr/local/mongo4.4.0/data/db","engine":"wiredTiger","journal":{"enabled":true}},"systemLog":{"destination":"file","logAppend":true,"path":"/usr/local/mongo4.4.0/logs/m
ongodb.log"}}}}
{"t":{"$date":"2020-08-31T16:23:50.989+08:00"},"s":"E",  "c":"STORAGE",  "id":20557,   "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error"
:"NonExistentPath: Data directory /usr/local/mongo4.4.0/data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or
 (2) by adding the 'storage.dbPath' option in the configuration file."}}
{"t":{"$date":"2020-08-31T16:23:50.989+08:00"},"s":"I",  "c":"NETWORK",  "id":20562,   "ctx":"initandlisten","msg":"Shutdown: going to close listening sockets"}
{"t":{"$date":"2020-08-31T16:23:50.989+08:00"},"s":"I",  "c":"-",        "id":20520,   "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."}
{"t":{"$date":"2020-08-31T16:23:50.989+08:00"},"s":"I",  "c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2020-08-31T16:23:50.989+08:00"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}      
{
  "t": <Datetime>, // timestamp
  "s": <String>, // severity
  "c": <String>, // component
  "ctx": <String>, // context
  "id": <String>, // unique identifier
  "msg": <String>, // message body
  "attr": <Object> // additional attributes (optional)
  "tags": <Array of strings> // tags (optional)
  "truncated": <Object> // truncation info (if truncated)
  "size": <Integer> // original size of entry (if truncated)
}      
  • Timestamp:時間戳,日志事件發生的時間
  • Serverity:日志資訊等級
  • F:Fatal
  • E:Error
  • W:Warning
  • I:Information
  • D1-D5:Debug級别,從4.2開始支援指定Debug級别。
  • Compontents:日志事件的分類
  • ACCESS:登入通路相關的資訊,例如登入驗證情況。
  • COMMAND:資料庫執行指令相關資訊,例如,查詢。
  • CONTROL:記錄控制管理相關的資訊,例如資料庫初始化。
  • ELECTION:副本集選舉相關資訊
  • FTDC:(full-time diagnostic data ) 全程檢測資料資訊,例如Server的狀态統計資訊。3.2新增
  • GEO:解析地理空間模型相關資訊。
  • INDEX:索引相關資訊,例如索引的建立過程資訊。
  • INITSYNC:初始化同步操作相關資訊
  • JOURNAL:日志相關的資訊
  • NETWORK:網絡相關資訊,例如網絡連接配接資訊。
  • QUERY:查詢相關資訊,例如查詢計劃資訊。
  • REPL:副本集相關資訊,包括:初始化同步,心疼,狀态,復原等資訊,包括ELECTION,INITSYSNC,REPL_HB和ROLLBACK。
  • REPL_HB:副本集心跳相關資訊
  • ROLLBACK:復原操作相關資訊
  • SHARDING:分片相關資訊,例如mongos的啟動資訊
  • STORAGE:存儲相關資訊,例如将 storage 層的資料刷入磁盤的資訊。
  • TXN:多文檔事務相關資訊,4.0.2新增
  • RECOVERY:還原活動相關的資訊
  • WRITE:寫操作相關的資訊,例如更新(update)的指令。
  • Context:産生該日志事件的線程名稱
  • id:日志語句的獨一無二的編号
  • Message:日志事件詳細資訊
  • Attributes:(可選)附件資訊,也就是發生該日志事件時的相關對象屬性,例如:作業系統版本,端口号,pid程序号等。
  • Tags:标簽
  • Truncated :日志截斷資訊
  • Size:發生日志截斷時,之前的日志檔案大小。