You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/concepts/cluster-administration/system-logs.md
+33-22Lines changed: 33 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,9 @@ weight: 80
11
11
12
12
System component logs record events happening in cluster, which can be very useful for debugging.
13
13
You can configure log verbosity to see more or less detail.
14
-
Logs can be as coarse-grained as showing errors within a component, or as fine-grained as showing step-by-step traces of events (like HTTP access logs, pod state changes, controller actions, or scheduler decisions).
14
+
Logs can be as coarse-grained as showing errors within a component, or as fine-grained as showing
15
+
step-by-step traces of events (like HTTP access logs, pod state changes, controller actions, or
16
+
scheduler decisions).
15
17
16
18
<!-- body -->
17
19
@@ -22,9 +24,9 @@ generates log messages for the Kubernetes system components.
22
24
23
25
For more information about klog configuration, see the [Command line tool reference](/docs/reference/command-line-tools-reference/).
24
26
25
-
Kubernetes is in the process of simplifying logging in its components. The
Migration to structured log messages is an ongoing process. Not all log messages are structured in this version. When parsing log files, you must also handle unstructured log messages.
85
+
Migration to structured log messages is an ongoing process. Not all log messages are structured in
86
+
this version. When parsing log files, you must also handle unstructured log messages.
84
87
85
88
Log formatting and value serialization are subject to change.
86
89
{{< /warning>}}
87
90
88
-
Structured logging introduces a uniform structure in log messages allowing for programmatic extraction of information. You can store and process structured logs with less effort and cost.
89
-
The code which generates a log message determines whether it uses the traditional unstructured klog output
90
-
or structured logging.
91
+
Structured logging introduces a uniform structure in log messages allowing for programmatic
92
+
extraction of information. You can store and process structured logs with less effort and cost.
93
+
The code which generates a log message determines whether it uses the traditional unstructured
94
+
klog output or structured logging.
91
95
92
-
The default formatting of structured log messages is as text, with a format that
93
-
is backward compatible with traditional klog:
96
+
The default formatting of structured log messages is as text, with a format that is backward
Strings are quoted. Other values are formatted with
106
110
[`%+v`](https://pkg.go.dev/fmt#hdr-Printing), which may cause log messages to
107
111
continue on the next line [depending on the data](https://github.com/kubernetes/kubernetes/issues/106428).
112
+
108
113
```
109
114
I1025 00:15:15.525108 1 example.go:116] "Example" data="This is text with a line break\nand \"quotation marks\"." someInt=1 someFloat=0.1 someStruct={StringField: First line,
JSON output does not support many standard klog flags. For list of unsupported klog flags, see the [Command line tool reference](/docs/reference/command-line-tools-reference/).
172
+
JSON output does not support many standard klog flags. For list of unsupported klog flags, see the
173
+
[Command line tool reference](/docs/reference/command-line-tools-reference/).
168
174
169
-
Not all logs are guaranteed to be written in JSON format (for example, during process start). If you intend to parse logs, make sure you can handle log lines that are not JSON as well.
175
+
Not all logs are guaranteed to be written in JSON format (for example, during process start).
176
+
If you intend to parse logs, make sure you can handle log lines that are not JSON as well.
170
177
171
178
Field names and JSON serialization are subject to change.
172
179
{{< /warning >}}
173
180
174
181
The `--logging-format=json` flag changes the format of logs from klog native format to JSON format.
175
182
Example of JSON log format (pretty printed):
183
+
176
184
```json
177
185
{
178
186
"ts": 1580306777.04728,
@@ -187,22 +195,24 @@ Example of JSON log format (pretty printed):
187
195
```
188
196
189
197
Keys with special meaning:
198
+
190
199
*`ts` - timestamp as Unix time (required, float)
191
200
*`v` - verbosity (only for info and not for error messages, int)
192
201
*`err` - error string (optional, string)
193
202
*`msg` - message (required, string)
194
203
195
-
196
204
List of components currently supporting JSON format:
The `-v` flag controls log verbosity. Increasing the value increases the number of logged events. Decreasing the value decreases the number of logged events.
205
-
Increasing verbosity settings logs increasingly less severe events. A verbosity setting of 0 logs only critical events.
213
+
The `-v` flag controls log verbosity. Increasing the value increases the number of logged events.
214
+
Decreasing the value decreases the number of logged events. Increasing verbosity settings logs
215
+
increasingly less severe events. A verbosity setting of 0 logs only critical events.
206
216
207
217
### Log location
208
218
@@ -228,3 +238,4 @@ The `logrotate` tool rotates logs daily, or once the log size is greater than 10
228
238
* Read about [Contextual Logging](https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/3077-contextual-logging)
229
239
* Read about [deprecation of klog flags](https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
230
240
* Read about the [Conventions for logging severity](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md)
0 commit comments