# Log to File

Action `doc.text`

`action.log_to_file`

Append a structured line to a log file on disk. Supports JSON Lines (.jsonl), plain text with customizable templates, and CSV formats. The file is created automatically if it does not exist. Each workflow execution appends one line.

Ideal for building audit trails, event logs, or data collection pipelines that can be analyzed later.

## Ports

Direction | Name | Data Type | Description
--- | --- | --- | ---
Input | Input | Any | Incoming payload to log
Output | Output | Any | Passthrough with log metadata

## Configuration

Field | Type | Default | Description
--- | --- | --- | ---
filePath | Text | — | Path to the log file (e.g., `~/logs/events.jsonl`)
format | Dropdown | `jsonl` | Log format: JSON Lines, Plain Text, or CSV
lineTemplate | Text Area | — | Template for each line. Supports `{{var}}`. Visible when format = text.
includeTimestamp | Boolean | `true` | Add an ISO 8601 timestamp to each JSON line. Visible when format = jsonl.

## Output Variables

Variable | Type | Description
--- | --- | ---
logFile | String | Absolute path to the log file
linesWritten | Number | Total number of lines in the file
written | Boolean | Whether the line was written successfully

## Example

Log API responses to a file on a schedule: