k3s/docs/yaml/kubectl/kubectl_logs.yaml

120 lines
4.0 KiB
YAML

name: logs
synopsis: Print the logs for a container in a pod.
description: |
Print the logs for a container in a pod. If the pod has only one container, the container name is optional.
options:
- name: container
shorthand: c
usage: Print the logs of this container
- name: follow
shorthand: f
default_value: "false"
usage: Specify if the logs should be streamed.
- name: include-extended-apis
default_value: "true"
usage: |
If true, include definitions of new APIs via calls to the API server. [default true]
- name: interactive
default_value: "false"
usage: If true, prompt the user for input when required.
- name: limit-bytes
default_value: "0"
usage: Maximum bytes of logs to return. Defaults to no limit.
- name: previous
shorthand: p
default_value: "false"
usage: |
If true, print the logs for the previous instance of the container in a pod if it exists.
- name: since
default_value: "0"
usage: |
Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only one of since-time / since may be used.
- name: since-time
usage: |
Only return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time / since may be used.
- name: tail
default_value: "-1"
usage: |
Lines of recent log file to display. Defaults to -1, showing all log lines.
- name: timestamps
default_value: "false"
usage: Include timestamps on each line in the log output
inherited_options:
- name: alsologtostderr
default_value: "false"
usage: log to standard error as well as files
- name: api-version
usage: |
DEPRECATED: The API version to use when talking to the server
- name: as
usage: Username to impersonate for the operation.
- name: certificate-authority
usage: Path to a cert. file for the certificate authority.
- name: client-certificate
usage: Path to a client certificate file for TLS.
- name: client-key
usage: Path to a client key file for TLS.
- name: cluster
usage: The name of the kubeconfig cluster to use
- name: context
usage: The name of the kubeconfig context to use
- name: insecure-skip-tls-verify
default_value: "false"
usage: |
If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
- name: kubeconfig
usage: Path to the kubeconfig file to use for CLI requests.
- name: log-backtrace-at
default_value: :0
usage: when logging hits line file:N, emit a stack trace
- name: log-dir
usage: If non-empty, write log files in this directory
- name: log-flush-frequency
default_value: 5s
usage: Maximum number of seconds between log flushes
- name: logtostderr
default_value: "true"
usage: log to standard error instead of files
- name: match-server-version
default_value: "false"
usage: Require server version to match client version
- name: namespace
usage: If present, the namespace scope for this CLI request.
- name: password
usage: Password for basic authentication to the API server.
- name: server
shorthand: s
usage: The address and port of the Kubernetes API server
- name: stderrthreshold
default_value: "2"
usage: logs at or above this threshold go to stderr
- name: token
usage: Bearer token for authentication to the API server.
- name: user
usage: The name of the kubeconfig user to use
- name: username
usage: Username for basic authentication to the API server.
- name: v
default_value: "0"
usage: log level for V logs
- name: vmodule
usage: |
comma-separated list of pattern=N settings for file-filtered logging
example: |-
# Return snapshot logs from pod nginx with only one container
kubectl logs nginx
# Return snapshot of previous terminated ruby container logs from pod web-1
kubectl logs -p -c ruby web-1
# Begin streaming the logs of the ruby container in pod web-1
kubectl logs -f -c ruby web-1
# Display only the most recent 20 lines of output in pod nginx
kubectl logs --tail=20 nginx
# Show all logs from pod nginx written in the last hour
kubectl logs --since=1h nginx
see_also:
- kubectl