Skip to content

Commit 4e39eba

Browse files
docs: add example output file format for WRANGLER_OUTPUT_FILE environment variables
Add a comprehensive example showing the ND-JSON format of the output file, including sample entries for wrangler-session and deploy operations, along with descriptions of other entry types (version-upload, version-deploy, pages-deploy, command-failed). Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
1 parent 207c75b commit 4e39eba

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/content/docs/workers/wrangler/system-environment-variables.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,23 @@ Wrangler supports the following environment variables:
9595

9696
- Specifies a directory where Wrangler will create a randomly-named file (format: `wrangler-output-<timestamp>-<random>.json`) to write output data in [ND-JSON](https://github.com/ndjson/ndjson-spec) format. This is useful when you want to keep output files organized in a specific directory but don't need to control the exact filename. If both `WRANGLER_OUTPUT_FILE_PATH` and `WRANGLER_OUTPUT_FILE_DIRECTORY` are set, `WRANGLER_OUTPUT_FILE_PATH` takes precedence.
9797

98+
### Example output file
99+
100+
When these environment variables are set, Wrangler writes one JSON object per line to the output file. Each entry includes a `timestamp` field and a `type` field indicating the kind of operation. Here's an example of what the file might contain after running `wrangler deploy`:
101+
102+
```json
103+
{"type":"wrangler-session","version":1,"wrangler_version":"3.78.0","command_line_args":["deploy"],"log_file_path":"/path/to/logs/wrangler-2024-11-03_12-00-00_abc.log","timestamp":"2024-11-03T12:00:00.000Z"}
104+
{"type":"deploy","version":1,"worker_name":"my-worker","worker_tag":"abc123def456","version_id":"v1-abc123","targets":["https://my-worker.example.workers.dev"],"worker_name_overridden":false,"wrangler_environment":"production","timestamp":"2024-11-03T12:00:05.000Z"}
105+
```
106+
107+
The `wrangler-session` entry is written when Wrangler starts and contains information about the command being run. The `deploy` entry is written when a deployment completes successfully and includes the worker name, version ID, and deployment URLs.
108+
109+
Other entry types include:
110+
- `version-upload` - Written by `wrangler versions upload` with version ID and preview URLs
111+
- `version-deploy` - Written by `wrangler versions deploy` with deployment information
112+
- `pages-deploy` - Written by `wrangler pages deploy` with Pages deployment details
113+
- `command-failed` - Written when a command fails, including error code and message
114+
98115
## Example `.env` file
99116

100117
The following is an example `.env` file:

0 commit comments

Comments
 (0)