1KUBERNETES(1)                      Jan 2015                      KUBERNETES(1)
2
3
4

NAME

6       kubectl logs - Print the logs for a container in a pod
7
8
9

SYNOPSIS

11       kubectl logs [OPTIONS]
12
13
14

DESCRIPTION

16       Print  the  logs for a container in a pod or specified resource. If the
17       pod has only one container, the container name is optional.
18
19
20

OPTIONS

22       --all-containers=false
23           Get all containers' logs in the pod(s).
24
25
26       -c, --container=""
27           Print the logs of this container
28
29
30       -f, --follow=false
31           Specify if the logs should be streamed.
32
33
34       --ignore-errors=false
35           If watching / following pod logs, allow for any errors  that  occur
36       to be non-fatal
37
38
39       --limit-bytes=0
40           Maximum bytes of logs to return. Defaults to no limit.
41
42
43       --max-log-requests=5
44           Specify maximum number of concurrent logs to follow when using by a
45       selector. Defaults to 5.
46
47
48       --pod-running-timeout=20s
49           The length of time (like 5s, 2m, or 3h, higher than zero)  to  wait
50       until at least one pod is running
51
52
53       -p, --previous=false
54           If  true, print the logs for the previous instance of the container
55       in a pod if it exists.
56
57
58       -l, --selector=""
59           Selector (label query) to filter on.
60
61
62       --since=0s
63           Only return logs newer than a relative duration like 5s, 2m, or 3h.
64       Defaults to all logs. Only one of since-time / since may be used.
65
66
67       --since-time=""
68           Only  return  logs after a specific date (RFC3339). Defaults to all
69       logs. Only one of since-time / since may be used.
70
71
72       --tail=-1
73           Lines of recent log file to display. Defaults to -1 with no  selec‐
74       tor, showing all log lines otherwise 10, if a selector is provided.
75
76
77       --timestamps=false
78           Include timestamps on each line in the log output
79
80
81

OPTIONS INHERITED FROM PARENT COMMANDS

83       --alsologtostderr=false
84           log to standard error as well as files
85
86
87       --application-metrics-count-limit=100
88           Max number of application metrics to store (per container)
89
90
91       --as=""
92           Username to impersonate for the operation
93
94
95       --as-group=[]
96           Group  to  impersonate for the operation, this flag can be repeated
97       to specify multiple groups.
98
99
100       --azure-container-registry-config=""
101           Path to the file containing Azure container registry  configuration
102       information.
103
104
105       --boot-id-file="/proc/sys/kernel/random/boot_id"
106           Comma-separated  list  of files to check for boot-id. Use the first
107       one that exists.
108
109
110       --cache-dir="/builddir/.kube/http-cache"
111           Default HTTP cache directory
112
113
114       --certificate-authority=""
115           Path to a cert file for the certificate authority
116
117
118       --client-certificate=""
119           Path to a client certificate file for TLS
120
121
122       --client-key=""
123           Path to a client key file for TLS
124
125
126       --cloud-provider-gce-lb-src-cidrs=130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
127           CIDRs opened in GCE firewall for LB traffic proxy  health checks
128
129
130       --cluster=""
131           The name of the kubeconfig cluster to use
132
133
134       --container-hints="/etc/cadvisor/container_hints.json"
135           location of the container hints file
136
137
138       --containerd="/run/containerd/containerd.sock"
139           containerd endpoint
140
141
142       --containerd-namespace="k8s.io"
143           containerd namespace
144
145
146       --context=""
147           The name of the kubeconfig context to use
148
149
150       --default-not-ready-toleration-seconds=300
151           Indicates    the    tolerationSeconds   of   the   toleration   for
152       notReady:NoExecute that is added by default to every pod that does  not
153       already have such a toleration.
154
155
156       --default-unreachable-toleration-seconds=300
157           Indicates  the  tolerationSeconds  of  the  toleration for unreach‐
158       able:NoExecute that is added by default to  every  pod  that  does  not
159       already have such a toleration.
160
161
162       --docker="unix:///var/run/docker.sock"
163           docker endpoint
164
165
166       --docker-env-metadata-whitelist=""
167           a  comma-separated  list of environment variable keys that needs to
168       be collected for docker containers
169
170
171       --docker-only=false
172           Only report docker containers in addition to root stats
173
174
175       --docker-root="/var/lib/docker"
176           DEPRECATED: docker root is read from docker info (this is  a  fall‐
177       back, default: /var/lib/docker)
178
179
180       --docker-tls=false
181           use TLS to connect to docker
182
183
184       --docker-tls-ca="ca.pem"
185           path to trusted CA
186
187
188       --docker-tls-cert="cert.pem"
189           path to client certificate
190
191
192       --docker-tls-key="key.pem"
193           path to private key
194
195
196       --enable-load-reader=false
197           Whether to enable cpu load reader
198
199
200       --event-storage-age-limit="default=0"
201           Max length of time for which to store events (per type). Value is a
202       comma separated list of key values, where  the  keys  are  event  types
203       (e.g.: creation, oom) or "default" and the value is a duration. Default
204       is applied to all non-specified event types
205
206
207       --event-storage-event-limit="default=0"
208           Max number of events to store (per type). Value is  a  comma  sepa‐
209       rated  list  of  key values, where the keys are event types (e.g.: cre‐
210       ation, oom) or "default" and  the  value  is  an  integer.  Default  is
211       applied to all non-specified event types
212
213
214       --global-housekeeping-interval=1m0s
215           Interval between global housekeepings
216
217
218       --housekeeping-interval=10s
219           Interval between container housekeepings
220
221
222       --insecure-skip-tls-verify=false
223           If true, the server's certificate will not be checked for validity.
224       This will make your HTTPS connections insecure
225
226
227       --kubeconfig=""
228           Path to the kubeconfig file to use for CLI requests.
229
230
231       --log-backtrace-at=:0
232           when logging hits line file:N, emit a stack trace
233
234
235       --log-cadvisor-usage=false
236           Whether to log the usage of the cAdvisor container
237
238
239       --log-dir=""
240           If non-empty, write log files in this directory
241
242
243       --log-file=""
244           If non-empty, use this log file
245
246
247       --log-file-max-size=1800
248           Defines the maximum size a log file can grow to. Unit is megabytes.
249       If the value is 0, the maximum file size is unlimited.
250
251
252       --log-flush-frequency=5s
253           Maximum number of seconds between log flushes
254
255
256       --logtostderr=true
257           log to standard error instead of files
258
259
260       --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
261           Comma-separated  list  of  files  to  check for machine-id. Use the
262       first one that exists.
263
264
265       --match-server-version=false
266           Require server version to match client version
267
268
269       -n, --namespace=""
270           If present, the namespace scope for this CLI request
271
272
273       --password=""
274           Password for basic authentication to the API server
275
276
277       --profile="none"
278           Name of profile to capture. One of (none|cpu|heap|goroutine|thread‐
279       create|block|mutex)
280
281
282       --profile-output="profile.pprof"
283           Name of the file to write the profile to
284
285
286       --request-timeout="0"
287           The  length  of  time  to  wait before giving up on a single server
288       request. Non-zero values should contain a corresponding time unit (e.g.
289       1s, 2m, 3h). A value of zero means don't timeout requests.
290
291
292       -s, --server=""
293           The address and port of the Kubernetes API server
294
295
296       --skip-headers=false
297           If true, avoid header prefixes in the log messages
298
299
300       --skip-log-headers=false
301           If true, avoid headers when opening log files
302
303
304       --stderrthreshold=2
305           logs at or above this threshold go to stderr
306
307
308       --storage-driver-buffer-duration=1m0s
309           Writes  in  the  storage driver will be buffered for this duration,
310       and committed to the non memory backends as a single transaction
311
312
313       --storage-driver-db="cadvisor"
314           database name
315
316
317       --storage-driver-host="localhost:8086"
318           database host:port
319
320
321       --storage-driver-password="root"
322           database password
323
324
325       --storage-driver-secure=false
326           use secure connection with database
327
328
329       --storage-driver-table="stats"
330           table name
331
332
333       --storage-driver-user="root"
334           database username
335
336
337       --token=""
338           Bearer token for authentication to the API server
339
340
341       --update-machine-info-interval=5m0s
342           Interval between machine info updates.
343
344
345       --user=""
346           The name of the kubeconfig user to use
347
348
349       --username=""
350           Username for basic authentication to the API server
351
352
353       -v, --v=0
354           number for the log level verbosity
355
356
357       --version=false
358           Print version information and quit
359
360
361       --vmodule=
362           comma-separated list of pattern=N settings for  file-filtered  log‐
363       ging
364
365
366

EXAMPLE

368                # Return snapshot logs from pod nginx with only one container
369                kubectl logs nginx
370
371                # Return snapshot logs from pod nginx with multi containers
372                kubectl logs nginx --all-containers=true
373
374                # Return snapshot logs from all containers in pods defined by label app=nginx
375                kubectl logs -lapp=nginx --all-containers=true
376
377                # Return snapshot of previous terminated ruby container logs from pod web-1
378                kubectl logs -p -c ruby web-1
379
380                # Begin streaming the logs of the ruby container in pod web-1
381                kubectl logs -f -c ruby web-1
382
383                # Begin streaming the logs from all containers in pods defined by label app=nginx
384                kubectl logs -f -lapp=nginx --all-containers=true
385
386                # Display only the most recent 20 lines of output in pod nginx
387                kubectl logs --tail=20 nginx
388
389                # Show all logs from pod nginx written in the last hour
390                kubectl logs --since=1h nginx
391
392                # Return snapshot logs from first container of a job named hello
393                kubectl logs job/hello
394
395                # Return snapshot logs from container nginx-1 of a deployment named nginx
396                kubectl logs deployment/nginx -c nginx-1
397
398
399
400

SEE ALSO

402       kubectl(1),
403
404
405

HISTORY

407       January  2015,  Originally compiled by Eric Paris (eparis at redhat dot
408       com) based on the kubernetes source material, but hopefully  they  have
409       been automatically generated since!
410
411
412
413Eric Paris                  kubernetes User Manuals              KUBERNETES(1)
Impressum