# PM2 Log Management

#### You:
how do i see logs in pm2 

#### ChatGPT:
To view logs in PM2, use these common commands:

### Show live logs for all processes

```bash
pm2 logs
```

### Show logs for a specific app

By app name:

```bash
pm2 logs my-app
```

By process ID:

```bash
pm2 logs 0
```

### Show only the last N lines

```bash
pm2 logs --lines 100
```

### View raw log files directly

PM2 stores logs under:

```bash
~/.pm2/logs/
```

List them:

```bash
ls ~/.pm2/logs
```

Tail a specific log:

```bash
tail -f ~/.pm2/logs/my-app-out.log
```

Error log only:

```bash
tail -f ~/.pm2/logs/my-app-error.log
```

### Useful PM2 log management commands

Flush all logs:

```bash
pm2 flush
```

Reload logs after logrotate:

```bash
pm2 reloadLogs
```

Install log rotation:

```bash
pm2 install pm2-logrotate
```

### Check running processes

```bash
pm2 list
```

Detailed info for one process:

```bash
pm2 describe my-app
```

Official docs: [PM2 Documentation](https://pm2.keymetrics.io/docs/usage/log-management/?utm_source=chatgpt.com)
