> ## Documentation Index
> Fetch the complete documentation index at: https://docs.instapods.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Logs

> View pod logs from the CLI.

View container and application logs for your pods.

## Basic Usage

```bash theme={null}
instapods logs my-app
```

Outputs the most recent log entries from the pod.

## Flags

| Flag | Description | Default |
| - | - | - |
| `-n` | Number of log lines to return | 100 |
| `-s` | Filter by service name | All services |
| `-g` | Only show entries matching this regex | No filter |

## Searching

`-n` reads back the tail of the journal, so an error from a while ago falls off
the end. `-g` searches the whole journal instead: it returns the last `-n`
entries that **match**, however far back they are.

```bash theme={null}
# Every connection refusal still in the journal
instapods logs my-app -g ECONNREFUSED

# Combined with a service filter and a limit
instapods logs my-app -s app -g 'error|fatal' -n 50
```

Three things to know about the search:

* **The pattern is a regex** (PCRE), matched against the message text —
  `error|fatal`, `5\d\d`, `user_id=42` all work. Quote it so your shell doesn't
  expand it first.
* **Case follows the pattern.** An all-lowercase pattern matches
  case-insensitively; one uppercase character makes it case-sensitive. So
  `-g error` finds `Error` and `ERROR`, while `-g Error` finds only `Error`.
* **Matches print newest first**, the opposite order to an unfiltered read.

A search covers **every** service, including the ones the preset default hides.
That is deliberate: an unfiltered `instapods logs my-app` on a Node.js pod reads
the `app` unit, but the kernel's OOM-killer lines and nginx's 502s live in other
units — exactly the things you search for because you can't see them. Add `-s`
to scope a search to one service.

`-- No entries --` means the search ran and nothing matched.

## Examples

```bash theme={null}
# Last 50 lines
instapods logs my-app -n 50

# Only application logs
instapods logs my-app -s app

# Only nginx access logs
instapods logs my-app -s nginx

# System logs
instapods logs my-app -s system

# Find an error that scrolled off the tail
instapods logs my-app -g 'out of memory'
```

## Service Filters

The available service filters depend on the pod's preset:

| Preset | Available Services |
| - | - |
| **Static** | `nginx`, `system` |
| **PHP** | `nginx`, `php-fpm`, `system` |
| **Node.js** | `app`, `system` |
| **Python** | `app`, `system` |

If you've installed database services, their logs are also available:

```bash theme={null}
instapods logs my-app -s mysql
instapods logs my-app -s postgresql
instapods logs my-app -s redis
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.