共計(jì) 4138 個(gè)字符,預(yù)計(jì)需要花費(fèi) 11 分鐘才能閱讀完成。
這篇文章主要介紹“MongoDB 的 JSON 格式日志是什么”,在日常操作中,相信很多人在 MongoDB 的 JSON 格式日志是什么問(wèn)題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”MongoDB 的 JSON 格式日志是什么”的疑惑有所幫助!接下來(lái),請(qǐng)跟著丸趣 TV 小編一起來(lái)學(xué)習(xí)吧!
從 4.4 版本開(kāi)始,MongoDB 的 mongo 和 mongos 日志文件格式采用了 JSON 格式,更容易分析、解析。在此之前和其他日志文件格式一樣,純文本輸出。
4.4 日志格式
JSON 格式更清晰,也更細(xì)分析、解析,非常方便。
{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}}
KEY 縮寫(xiě):
{
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)
}
KEY 說(shuō)明:
Timestamp:時(shí)間戳,日志事件發(fā)生的時(shí)間
Serverity:日志信息等級(jí)
F:Fatal
E:Error
W:Warning
I:Information
D1-D5:Debug 級(jí)別,從 4.2 開(kāi)始支持指定 Debug 級(jí)別。
Compontents:日志事件的分類(lèi)
ACCESS:登入訪(fǎng)問(wèn)相關(guān)的信息,例如登錄驗(yàn)證情況。
COMMAND:數(shù)據(jù)庫(kù)執(zhí)行命令相關(guān)信息,例如,查詢(xún)。
CONTROL:記錄控制管理相關(guān)的信息,例如數(shù)據(jù)庫(kù)初始化。
ELECTION:副本集選舉相關(guān)信息
FTDC:(full-time diagnostic data)全程檢測(cè)數(shù)據(jù)信息,例如 Server 的狀態(tài)統(tǒng)計(jì)信息。3.2 新增
GEO:解析地理空間模型相關(guān)信息。
INDEX:索引相關(guān)信息,例如索引的創(chuàng)建過(guò)程信息。
INITSYNC:初始化同步操作相關(guān)信息
JOURNAL:日志相關(guān)的信息
NETWORK:網(wǎng)絡(luò)相關(guān)信息,例如網(wǎng)絡(luò)連接信息。
QUERY:查詢(xún)相關(guān)信息,例如查詢(xún)計(jì)劃信息。
REPL:副本集相關(guān)信息,包括:初始化同步,心疼,狀態(tài),回滾等信息,包括 ELECTION,INITSYSNC,REPL_HB 和 ROLLBACK。
REPL_HB:副本集心跳相關(guān)信息
ROLLBACK:回滾操作相關(guān)信息
SHARDING:分片相關(guān)信息,例如 mongos 的啟動(dòng)信息
STORAGE:存儲(chǔ)相關(guān)信息,例如將 storage 層的數(shù)據(jù)刷入磁盤(pán)的信息。
TXN:多文檔事務(wù)相關(guān)信息,4.0.2 新增
RECOVERY:還原活動(dòng)相關(guān)的信息
WRITE:寫(xiě)操作相關(guān)的信息,例如更新(update)的命令。
Context:產(chǎn)生該日志事件的線(xiàn)程名稱(chēng)
id:日志語(yǔ)句的獨(dú)一無(wú)二的編號(hào)
Message:日志事件詳細(xì)信息
Attributes:(可選) 附件信息,也就是發(fā)生該日志事件時(shí)的相關(guān)對(duì)象屬性,例如:操作系統(tǒng)版本,端口號(hào),pid 進(jìn)程號(hào)等。
Tags:標(biāo)簽
Truncated:日志截?cái)嘈畔?
Size:發(fā)生日志截?cái)鄷r(shí),之前的日志文件大小。
到此,關(guān)于“MongoDB 的 JSON 格式日志是什么”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注丸趣 TV 網(wǎng)站,丸趣 TV 小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!