Canonical: https://weaveos.com/reference/kubernetes/read-previous-container-logs

1. [Software capabilities](https://weaveos.com/reference)
2. /[Kubernetes](https://weaveos.com/reference/kubernetes)
3. /Read logs from a restarted Kubernetes container

Kubernetes capability

# Read logs from a restarted Kubernetes container

Use kubectl logs --previous to view the prior container instance’s logs. A client with access to the Pod log subresource can make the same request using previous=true.

Documentation reviewed November 26, 2026

## Ways to do it

CLI

### kubectl logs --previous

Specify the namespace, pod, and container to read the prior container instance’s available logs.

- Requirements

  A kubeconfig for the cluster and permission to read the pod and its logs.

- Limitations

  kubectl logs only returns the latest log file. Use a separate logging backend to retain logs beyond container log rotation.

Example

```
kubectl logs -n "$NAMESPACE" "$POD" -c "$CONTAINER" --previous
```

[Read source: Kubernetes container logging and rotation ↗](https://kubernetes.io/docs/concepts/cluster-administration/logging/)

API

### GET /api/v1/namespaces/{namespace}/pods/{name}/log

Set previous=true and name the container. Use tailLines or limitBytes to bound the response.

- Requirements

  Cluster API access with get permission for the pods/log subresource in the namespace.

- Limitations

  This reads available container logs from the pod log subresource. The endpoint does not reconstruct old logs after they are gone.

[Read source: Kubernetes v1.36 Pod API log subresource ↗](https://v1-36.docs.kubernetes.io/docs/reference/kubernetes-api/core/pod-v1/#get-read-log)
