# Read logs and open a shell > Stream live logs from an Orchard app, read the output of containers that crashed, open a shell in a running container, and diagnose a crash loop. Source: https://docs.orchard.hackclub.com/run/logs/ When an app misbehaves, its logs and a shell inside its container are usually the fastest way to find out why. Use the console on the app's **Overview** tab to follow what the app is doing now, read the output of a container that crashed, or run commands in a container. To search older logs, use **Observe** > **Logs**, described in [Monitor an app](/run/monitor-an-app/). ## Stream live logs **Dashboard** 1. Open the app. 2. Go to **Overview**. 3. In the console, select **Logs**. 4. To follow one replica, open the source menu. 5. Select a pod and container. **CLI** ```sh orchard logs --follow ``` To read [build logs](/deploy/builds/#troubleshoot-a-failed-build), add `--build`. ## Read past logs Past logs include replicas that have since been replaced. They come from the instance's log store. If the view is empty, refer to [Configure logs and request data](/operate/logs/). 1. Open the app. 2. Go to **Observe** > **Logs**. 3. Select a time range. ## Read crash output Orchard captures the final output of a container that was killed, including out-of-memory (OOM) kills. It attaches the output to the app. **Dashboard** 1. Open the app. 2. Go to **Overview**. 3. In the console, open the source menu. 4. Select the entry for the container labeled **Output from before the last crash**. **CLI** ```sh orchard deploy killed list orchard deploy killed logs ``` ## Diagnose a crash loop In a crash loop, a container starts and exits, and Kubernetes restarts it. Read the exit reason and the last logs. | Symptom | Likely cause | What to do | | ------------------------------------------------- | -------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | Exits immediately with a module or import error | The image is missing a dependency, or the build used the wrong stage | Check the [build stage](/deploy/builds/#the-image-has-no-application-in-it) | | Exits after a few seconds with connection refused | The app cannot reach its database | Check the [internal host](/data/databases/#get-a-connection-string) and the credentials | | Killed with exit code 137 | The container ran out of memory | Raise the [memory limit](/deploy/scaling/#set-cpu-and-memory) or fix the leak | | Runs but never becomes ready | The health check path or port is wrong | Check [health checks](/deploy/scaling/#set-health-checks) | ## Open a shell A shell opens a terminal inside a running container. It uses the same authentication as the dashboard. **Dashboard** 1. Open the app. 2. Go to **Overview**. 3. In the console, select **Shell**. 4. If the app has more than one pod or container, select one. **CLI** The CLI runs one command at a time in a pod. It does not open an interactive shell. ```sh orchard pod exec -- env ``` To open the app's language REPL in a pod, run `orchard console `. Changes you make in a shell are lost on the next restart. A command that uses too much memory can cause Kubernetes to kill the container. ## Database logs A database has the same console on its **Overview** tab. - **Logs** streams the logs of an instance. - **Killed** lists containers killed in the last 24 hours, with their final output. - **Shell** opens a terminal in an instance. To open `psql` from the CLI, run `orchard db psql `. ## Kubernetes events **Observe** > **Events** lists crashes and Kubernetes warnings for the app's pods, newest first. It includes failed scheduling, image pull problems, probe failures, and volume mounts. It also shows how many times each one repeated. The alert banner above an app's tabs shows only problems that exist now. Kubernetes keeps warning events for about an hour after a problem clears, so the history can show warnings the banner does not. ## Related resources - [Metrics and alerts](/run/observability/) - Find where Orchard shows metrics, current problems, and alerts. - [Builds](/deploy/builds/) - Read build logs and fix a build that fails. - [`orchard logs` reference](/reference/cli/#logs) - Every `orchard logs` flag.