@@ -81,10 +81,15 @@ analyzing structured log messages can be found in the
81
81
JSON Log Output Format
82
82
~~~~~~~~~~~~~~~~~~~~~~
83
83
84
- With MongoDB 4.4, all log output is now in JSON format. This includes
85
- log output sent to the *file*, *syslog*, and *stdout* (standard out)
86
- :ref:`log destinations <log-message-destinations>`, as well as the
87
- output of the :dbcommand:`getLog` command.
84
+ Starting in MongoDB 4.4, all log output is in JSON format including
85
+ output sent to:
86
+
87
+ - Log file
88
+ - Syslog
89
+ - Stdout (standard out) :ref:`log destinations
90
+ <log-message-destinations>`
91
+
92
+ Output from the :dbcommand:`getLog` command is also in JSON format.
88
93
89
94
Each log entry is output as a self-contained JSON object which follows
90
95
the :doc:`Relaxed Extended JSON v2.0 </reference/mongodb-extended-json>`
@@ -97,55 +102,82 @@ specification, and has the following layout and field order:
97
102
"t": <Datetime>, // timestamp
98
103
"s": <String>, // severity
99
104
"c": <String>, // component
100
- "ctx": <String>, // context
101
105
"id": <Integer>, // unique identifier
106
+ "ctx": <String>, // context
102
107
"msg": <String>, // message body
103
108
"attr": <Object> // additional attributes (optional)
104
109
"tags": <Array of strings> // tags (optional)
105
110
"truncated": <Object> // truncation info (if truncated)
106
111
"size": <Integer> // original size of entry (if truncated)
107
112
}
108
113
109
- - **Timestamp** - Timestamp of the log message, in ``ISO-8601``
110
- format. See :ref:`log-message-timestamp`.
111
-
112
- - **Severity** - String representing the short severity code of the log
113
- message. See :ref:`log-severity-levels`.
114
-
115
- - **Component** - String representing the full component string of the
116
- log message. See :ref:`log-message-components`.
117
-
118
- - **Context** - String representing the name of the thread issuing the
119
- log statement.
114
+ Field descriptions:
120
115
121
- - **id** - Integer representing the unique identifier of the log
122
- statement. See :ref:`log-message-parsing-example-filter-id` for an
123
- example.
124
-
125
- - **Message** - String representing the raw log output message as passed
126
- from the server or driver. This message is :ref:`escaped as needed
127
- <log-message-json-escaping>` according to the JSON specification.
128
-
129
- - **Attributes** - *(optional)* Object containing one or more
130
- key-value pairs for any additional attributes provided. If a log
131
- message does not include any additional attributes, this object is
132
- omitted. Attribute values may be referenced by their key name in the
133
- *message* body, depending on the message. Like **message**, attributes
134
- are :ref:`escaped as needed <log-message-json-escaping>` according to
135
- the JSON specification.
136
-
137
- - **Tags** - *(optional)* Array of strings representing any tags
138
- applicable to the log statement, for example: ``["startupWarnings"]``.
116
+ .. list-table::
117
+ :header-rows: 1
118
+ :widths: 10 10 50
139
119
140
- - **Truncated** - *(if truncated)* Object containing information
141
- regarding :ref:`log message truncation <log-message-truncation>`, if
142
- applicable. This object will only be present if the log entry contains
143
- at least one **attribute** that was truncated.
120
+ * - Field Name
121
+ - Type
122
+ - Description
144
123
145
- - **Size** - *(if truncated)* Integer representing the original size of
146
- a log entry if it has been :ref:`truncated <log-message-truncation>`.
147
- This field will only be present if the log entry contains
148
- at least one **attribute** that was truncated.
124
+ * - ``t``
125
+ - Datetime
126
+ - Timestamp of the log message in ISO-8601 format. For an example,
127
+ see :ref:`log-message-timestamp`.
128
+
129
+ * - ``s``
130
+ - String
131
+ - Short severity code of the log message. For an example, see
132
+ :ref:`log-severity-levels`.
133
+
134
+ * - ``c``
135
+ - String
136
+ - Full component string for the log message. For an example, see
137
+ :ref:`log-message-components`.
138
+
139
+ * - ``id``
140
+ - Integer
141
+ - Unique identifier for the log statement. For an example, see
142
+ :ref:`log-message-parsing-example-filter-id`.
143
+
144
+ * - ``ctx``
145
+ - String
146
+ - Name of the thread that caused the log statement.
147
+
148
+ * - ``msg``
149
+ - String
150
+ - Log output message passed from the server or driver. If
151
+ necessary, the message is :ref:`escaped
152
+ <log-message-json-escaping>` according to the JSON specification.
153
+
154
+ * - ``attr``
155
+ - Object
156
+ - One or more key-value pairs for additional log attributes. If a
157
+ log message does not include any additional attributes, the
158
+ ``attr`` object is omitted.
159
+
160
+ Attribute values may be referenced by their key name in the
161
+ ``msg`` message body, depending on the message. If necessary, the
162
+ attributes are :ref:`escaped <log-message-json-escaping>`
163
+ according to the JSON specification.
164
+
165
+ * - ``tags``
166
+ - Array of strings
167
+ - Strings representing any tags applicable to the log statement.
168
+ For example, ``["startupWarnings"]``.
169
+
170
+ * - ``truncated``
171
+ - Object
172
+ - Information about the :ref:`log message truncation
173
+ <log-message-truncation>`, if applicable. Only included if the
174
+ log entry contains at least one truncated ``attr`` attribute.
175
+
176
+ * - ``size``
177
+ - Integer
178
+ - Original size of a log entry if it has been :ref:`truncated
179
+ <log-message-truncation>`. Only included if the log entry
180
+ contains at least one truncated ``attr`` attribute.
149
181
150
182
.. _log-message-json-escaping:
151
183
0 commit comments