Show–Logs - anongitmous/k8sShell GitHub Wiki
Stream pod and container logs to the console.
[-Containers] <Mtf.Kubernetes.Models.V1K8sContainer[]>
[-BytesLimit <Int32>]
[-SelectString <String>]
[-Since <String>]
[-SinceTime <DateTime>]
[-TailLines <Int32>]
[-DoNotRetryDroppedConnections]
[-NoPrefix] [-SkipTlsVerify]
[-Timestamps]
[<CommonParameters>]
[-Pods] <Mtf.Kubernetes.Models.V1K8sPod[]>
[-ContainerName <String>]
[-BytesLimit <Int32>]
[-SelectString <String>]
[-Since <String>]
[-SinceTime <DateTime>]
[-TailLines <Int32>]
[-DoNotRetryDroppedConnections]
[-NoPrefix] [-SkipTlsVerify]
[-Timestamps]
[<CommonParameters>]
For every result of Get–Pods or Get–Containers piped into this cmdlet, stream the logs to the console.
If there are more than a single container's logs being streamed, then each log line emitted is prefixed with the pod name, and if necessary, the container name as well. This can be disabled via the use of the -NoPrefix argument.
The default behavior is to stream the entirety of the logs. This can be modified via one of the -BytesLimit, -Since, -SinceTime, or -TailLines arguments.
The logs are streamed in parallel.
ℹ️ See A Note about the Examples
1. Stream the logs from every pod according to the currently active cluster configuration
- If the
ContainerNameargument is not supplied, then the source pods in this example must have a single container. If not, then the log streaming operation will fail for that pod.- Using aliasing, the above can be shortened to
ksgp | ksdl
2. Stream the logs from every container in every pod according to the currently active cluster configuration
- Using aliasing, the above can be shortened to
ksgp | ksgc | ksdl
3. Stream the most recent five minutes of logs from every pod according to the currently active cluster configuration
- If the
ContainerNameargument is not supplied, then the source pods in this example must have a single container. If not, then the log streaming operation will fail for that pod.- Using aliasing, the above can be shortened to
ksgp | ksdl -Since 5m
4. Stream the logs from every container in every pod according to the currently active cluster configuration, only displaying matches for the -SelectString argument
- Using aliasing, the above can be shortened to
ksgp | ksdl -SelectString 'to_match'
-Containers
- The container(s) resulting from a call to Get–Containers from which to stream logs.
| Type: | Mtf.Kubernetes.Models.V1K8sContainer[] |
| Aliases: | |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
-Pods
- The pod(s) resulting from a call to Get–Pods from which to stream logs.
| Type: | Mtf.Kubernetes.Models.V1K8sPod[] |
| Aliases: | |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
-ContainerName
- The name of the container from which to stream logs.
- Specify along with the
-Podsparameter to specify which container from which to stream logs when the pods have more than a single container.
| Type: | String |
| Aliases: | |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-BytesLimit
- The maximum bytes of a log to return.
- Defaults to no limit.
| Type: | Int32 |
| Aliases: | |
| Position: | Named |
| Default value: | No Limit |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-SelectString
- A regular expression that will result in only matching log lines being displayed in the console.
| Type: | String |
| Aliases: | |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-Since
- The relative time in seconds before the current time from which to stream logs.
- If this value precedes the time a pod was started, all log lines will be returned.
- If this value is in the future, no log lines will be returned.
- Input format:
- 60 - 60 seconds. integers are interpreted as seconds.
- 60s - 60 seconds
- 10m - 10 minutes
- 1h - 1 hour
- 1d - 1 day
- Only one of
-Sinceor-SinceTimemay be specified.
| Type: | String |
| Aliases: | |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-SinceTime
- Only return logs after a specific date (RFC3339).
- Defaults to all logs.
- Only one of
-SinceTimeor-Sincemay be used.
| Type: | DateTime |
| Aliases: | |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-TailLines
- The number of lines from the end of the logs to show.
- If not specified, logs are shown from the creation of the container or
-Sinceor-SinceTime.
| Type: | Int32 |
| Aliases: | |
| Position: | Named |
| Default value: | No Limit |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-NoPrefix
- By default, each log line displays the pod and/or container name.
- Specify this to remove the source pod and/or container name from each log line.
| Type: | SwitchParameter |
| Aliases: | |
| Position: | Named |
| Default value: | False |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-SkipTlsVerify
- Skip verifying the identity of the kubelet from which logs are requested.
| Type: | SwitchParameter |
| Aliases: | |
| Position: | Named |
| Default value: | False |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-Timestamps
- Add timestamps to each line of log output.
| Type: | SwitchParameter |
| Aliases: | |
| Position: | Named |
| Default value: | False |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
K8sShell includes the following alias for Show-Logs:
- ksdl
- Because
ksslis already used by Save–Logs, the 'dl' here is for 'display logs'
- Because