# Logs and log drains

> Read the server journal and log files with secrets masked, let customers search their own web, PHP, WAF, app and container logs, follow logs live, and forward logs to syslog over TLS, HTTPS JSON or Grafana Loki.

Source: https://www.berthpanel.app/library/logs-and-log-drains/ · Category: monitoring · Updated: 2026-10-30

Most problems on a hosting server are solved by reading the right log at the right moment. Berth puts those logs in the panel, for administrators and for customers, so nobody needs a shell to see why a site returns 502 or which IP address is hammering `wp-login.php`. When logs have to go somewhere else, a SIEM or your own log platform, log drains forward them continuously.

## Server logs for administrators

*System → Logs* shows the systemd journal and the server's fixed log files.

- **Filters**: unit or service, program (`SYSLOG_IDENTIFIER`), priority (from *error* up to *info*), period (quick picks or your own range in server time), boot (this boot or the previous one), and kernel messages only.
- **Search** is literal and case-insensitive.
- **Watch live** streams new lines as they arrive.
- **Log file**: services that also write to files, such as the mail log or the web server's error log, are listed with their path for this operating system. Open one to read its tail.

Secrets (passwords, tokens, keys) are masked by the server before lines reach the browser, the API or the CLI. The same view is available as `GET /api/v1/system/logs`.

```bash
berth logs --unit nginx --priority err --since 1h
berth logs --unit postfix --grep "status=bounced" --since "2026-10-28 08:00"
berth logs --kernel --boot -1             # kernel messages of the previous boot
berth logs --unit berth-backup --follow
berth logs files                          # fixed log files with their key and path
berth logs file nginx-error --follow
```

`--since` and `--until` accept RFC 3339, `2026-10-11 08:00` in server time, Unix seconds or a duration back from now (`15m`, `1h`, `7d`). Add `--json` for machine-readable output with priority, unit and PID per line.

For noticing patterns rather than reading lines, *System → Events* collects OOM kills, disk and file system errors, crashes, unexpected reboots and anomalies found in the logs. See [services and diagnostics](https://www.berthpanel.app/library/services-and-diagnostics/).

## Logs of a website

Every domain has its own *Logs* page, linked from the domain's overview, with an access log and error logs that are read for you rather than just printed:

- **Access log**: requests grouped by outcome (success, redirects, not found or refused, server errors, blocked by the firewall), the most requested paths, the paths with most 4xx or 5xx, and the most suspicious addresses.
- **PHP errors**: identical errors and warnings grouped, with the first stack frame.
- **Slow requests**: from the PHP-FPM slow log, which scripts were slow and what they were waiting for, often a database (`mysqli_query`) or an outgoing request (`curl_exec`).
- **WAF**: requests the web application firewall blocked or only reported, with the rules they matched. See [WAF](https://www.berthpanel.app/library/waf/).

Each log can be searched and followed live. On the command line:

```bash
berth domain logs --domain acme.nl --kind access --lines 200
berth domain logs --domain acme.nl --kind php_error --follow
```

The kinds are `access`, `error`, `proxy_access`, `proxy_access_ssl`, `proxy_error`, `php_error`, `php_slow` and `waf`. The files themselves live in the Plesk-compatible layout under `/var/www/vhosts/system/<domain>/logs/`, see [on-disk layout](https://www.berthpanel.app/library/on-disk-layout/).

## Searching across a subscription

When a problem spans several sites, apps or containers, customers use *Statistics → Logs* (for customers the menu reads *Usage*). It searches one source or all of them at once, newest hit first, including rotated copies (`.N.gz`).

Sources:

- `web:<domain>` (or `web:*` for all websites): every request, with a status filter for `429`, `4xx`, `5xx` or `gw` (502 to 504, when the site did not answer in time),
- `err:` web server errors, `php:` PHP errors, `slow:` slow requests, `waf:` ModSecurity,
- `app:<domain>/<name>` Node.js, Python and PHP workers, and `container:<name>` containers, both from the journal,
- `all:*` everything together.

Periods are 1 hour, 24 hours, 7 days or 14 days, or your own range. **Live** shows new lines at the top as they arrive. A search term is literal: a path (`/wp-login.php`), an address or part of an error message. If a period is too large to read in one go, the page says so and tells you which part was skipped, instead of silently returning partial results.

```bash
berth logs sources acme_nl
berth logs search acme_nl --src web:shop.acme.nl --status 429 --window 7d
berth logs search acme_nl --src php:shop.acme.nl --grep "Fatal error"
berth logs search acme_nl --src 'all:*' --grep 203.0.113.7
berth logs search acme_nl --src container:ghost --since 2h
```

Searches are rate-limited per subscription, so one customer's searches cannot slow down the server for others.

## Log drains: forwarding logs

A log drain sends log lines continuously to a system you run. Berth supports three protocols:

| Kind | Destination | Typical receivers |
|---|---|---|
| `syslog` | `syslog+tls://host:port`, RFC 5424 messages over TLS (RFC 5425) | Wazuh, Splunk, Elastic, Microsoft Sentinel, rsyslog |
| `http` | `https://…`, batches as a JSON array | Vector, Logstash, Fluent Bit, your own service |
| `loki` | the push API of Grafana Loki, with labels per source and domain | Grafana Loki, optionally multi-tenant |

Berth keeps, per drain and per log file, how far it has sent. After an outage of the receiver it picks up where it stopped, and the drain list shows lines sent, the last success and the last error. Enabling a drain that was off starts from that moment.

### Drains for a subscription

Customers and administrators add these on the subscription's *Log drains* page, reached from the domain, button **Add log drain**. Choose:

- **Sources**: access (every request), error (web server), PHP (errors and slow scripts), WAF (stopped attacks), and apps (Node, Python, PHP workers and, when all domains are selected, the containers).
- **Domains**: nothing ticked means all domains, including ones added later.
- **Mask addresses**: visitor IP addresses are shortened before they leave the server, the last octet set to 0 for IPv4 and to a /48 for IPv6, the same as the panel's privacy setting. Useful when the receiver is outside your GDPR processing agreement; see [GDPR](https://www.berthpanel.app/library/gdpr/).
- **Login, own CA and client certificate**: an `Authorization` header (`Bearer …` or `Basic …`), a CA certificate in PEM if the receiver has no public certificate, a client certificate and key for **mutual TLS**, and the Loki tenant (`X-Scope-OrgID`).

Secrets are not shown again after saving. Use **Test** to send one test line.

```bash
berth logdrain add --subscription acme_nl --name loki --kind loki \
  --url https://loki.example.nl --sources access,error,php --tenant acme \
  --auth-file /root/loki-auth.txt --mask-ips
berth logdrain add --subscription acme_nl --name siem --kind syslog \
  --url syslog+tls://siem.example.nl:6514 --sources access,waf \
  --ca-file /root/siem-ca.pem --client-cert-file /root/acme.crt --client-key-file /root/acme.key
berth logdrain list --subscription acme_nl
berth logdrain test --subscription acme_nl --id 2
```

Pass the authorization value with `--auth-file`, never on the command line, where it would end up in the shell history.

### Drains for the server

Administrators can forward the server's own security logs to a SIEM under *System → Logs → Server log drains*:

- **auditd**: logins, sudo, changes to accounts and the audit rules the panel sets,
- **Logins**: sshd, sudo, su and login from the journal.

```bash
berth logdrain add --server --name wazuh --kind syslog \
  --url syslog+tls://siem.example.nl:6514 --sources auditd,auth --ca-file /root/siem-ca.pem
```

Berth's own activity log (who changed what in the panel) has its own syslog forwarder, `berth admin audit-syslog --target tls://host:port`, with optional mutual TLS; it is described in [audit trail and approvals](https://www.berthpanel.app/library/audit-trail-and-approvals/). For a full SIEM agent on the server, and NIS2 reporting, see [NIS2 and incidents](https://www.berthpanel.app/library/nis2-and-incidents/).

## Related

- [Services and diagnostics](https://www.berthpanel.app/library/services-and-diagnostics/)
- [Statistics and metrics](https://www.berthpanel.app/library/statistics-and-metrics/)
- [Notifications and alerts](https://www.berthpanel.app/library/notifications-and-alerts/)
- [Firewall and bans](https://www.berthpanel.app/library/firewall-and-bans/)
