MongoDB的JSON格式日志是什么

55次阅读
没有评论

共计 4138 个字符,预计需要花费 11 分钟才能阅读完成。

这篇文章主要介绍“MongoDB 的 JSON 格式日志是什么”,在日常操作中,相信很多人在 MongoDB 的 JSON 格式日志是什么问题上存在疑惑,丸趣 TV 小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”MongoDB 的 JSON 格式日志是什么”的疑惑有所帮助!接下来,请跟着丸趣 TV 小编一起来学习吧!

从 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}}

KEY 缩写:

{
  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 说明:

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:发生日志截断时,之前的日志文件大小。

到此,关于“MongoDB 的 JSON 格式日志是什么”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注丸趣 TV 网站,丸趣 TV 小编会继续努力为大家带来更多实用的文章!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-13发表,共计4138字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)