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

# Download OCPP Logs

This guide explains how to download OCPP logs from **Network Manager** and work with the exported data.

## Downloading Logs from Network Manager

1. Navigate to **Stations** and select the station you want to download logs for.
2. Open the **Real-Time Logs** tab.
3. Use the time range selector to choose the period you want to export.
4. Optionally filter logs by action type using the filter box.
5. Click the download button (arrow icon) to download the logs.

The logs will be downloaded as a `.jsonl` file (JSON Lines format).

**Download Limit:** Exports are limited to **500 logs** to prevent browser memory issues. If your date range contains more than 500 logs, the export will be truncated. Use a narrower date range or filters to get specific logs.

## JSONL File Format

The exported file uses the JSONL (JSON Lines) format, where each line is a separate JSON object. This format is optimized for streaming processing and works well with command-line tools.

### File Structure

**Line 1 - Header:**

```json theme={null}
{"type":"header","exportedAt":"2024-01-15T10:30:00.000Z","stationId":"ABC123","dateRange":{"start":"2024-01-15T09:00:00.000Z","end":"2024-01-15T10:30:00.000Z"},"totalMessages":42}
```

**Subsequent Lines - OCPP Messages:**

Each line is a raw OCPP message in array format:

* **CALL (Request):** `[2, "message-id", "ActionName", {payload}]`
* **CALLRESULT (Response):** `[3, "message-id", {payload}]`
* **CALLERROR (Error):** `[4, "message-id", "ErrorCode", "ErrorDescription", {details}]`

### Example File Content

```jsonl theme={null}
{"type":"header","exportedAt":"2024-01-15T10:30:00.000Z","stationId":"EVSE001","dateRange":{"start":"2024-01-15T09:00:00.000Z","end":"2024-01-15T10:30:00.000Z"},"totalMessages":4}
[2,"20240115T093000000Z-Heartbeat","Heartbeat",{}]
[3,"20240115T093000000Z-Heartbeat",{"currentTime":"2024-01-15T09:30:00.000Z"}]
[2,"20240115T094500000Z-StatusNotification","StatusNotification",{"connectorId":1,"status":"Available","errorCode":"NoError"}]
[3,"20240115T094500000Z-StatusNotification",{}]
```

## Working with JSONL Files

### Using jq (Command Line)

[jq](https://stedolan.github.io/jq/) is a powerful command-line JSON processor that works great with JSONL files.

**View the header:**

```bash theme={null}
head -1 ocpp-logs-EVSE001-2024-01-15.jsonl | jq
```

**Count total messages (excluding header):**

```bash theme={null}
tail -n +2 ocpp-logs-EVSE001-2024-01-15.jsonl | wc -l
```

**Find all Heartbeat requests:**

```bash theme={null}
tail -n +2 ocpp-logs-EVSE001-2024-01-15.jsonl | jq -c 'select(.[0] == 2 and .[2] == "Heartbeat")'
```

**Find all error responses:**

```bash theme={null}
tail -n +2 ocpp-logs-EVSE001-2024-01-15.jsonl | jq -c 'select(.[0] == 4)'
```

**Extract all action names from requests:**

```bash theme={null}
tail -n +2 ocpp-logs-EVSE001-2024-01-15.jsonl | jq -r 'select(.[0] == 2) | .[2]' | sort | uniq -c | sort -rn
```

**Filter StatusNotification messages and pretty print:**

```bash theme={null}
tail -n +2 ocpp-logs-EVSE001-2024-01-15.jsonl | jq 'select(.[0] == 2 and .[2] == "StatusNotification")'
```

### Using grep

For simple text searches:

```bash theme={null}
# Find all lines containing "Authorize"
grep "Authorize" ocpp-logs-EVSE001-2024-01-15.jsonl

# Find all error responses (message type 4)
grep '^\[4,' ocpp-logs-EVSE001-2024-01-15.jsonl
```

## OCPP Message Types Reference

| Type | Name       | Description                                    |
| ---- | ---------- | ---------------------------------------------- |
| 2    | CALL       | Request message from station or central system |
| 3    | CALLRESULT | Successful response to a CALL                  |
| 4    | CALLERROR  | Error response to a CALL                       |

## Tips

* Messages are sorted by timestamp in ascending order (oldest first).
* The message ID in each OCPP message is generated from the timestamp and action name.
* Use `tail -n +2` to skip the header line when processing only messages.
* The JSONL format allows processing large log files without loading everything into memory.
