worker-logs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Check Cloudflare Worker logs

查看Cloudflare Worker日志

Use this skill when you need to see what is happening inside the deployed Workers: request paths, response status, console.log output, and errors. Both the main site and the API are separate Cloudflare Workers.
当你需要了解已部署的Worker内部运行情况时,可以使用该技能:查看请求路径、响应状态、console.log输出以及错误信息。主站点和API是独立的Cloudflare Worker。

When to use this skill

何时使用该技能

  • Debugging 401/500 from openagents.com or openagents.com/api.
  • Verifying that a Worker receives the expected headers (e.g. X-OA-Internal-Key) and why it might return "unauthorized".
  • Seeing console.log / console_error! output from the Rust API or the web app.
  • Correlating with Convex logs (Convex calls the API worker; tail the API worker while reproducing).
  • 调试openagents.com或openagents.com/api返回的401/500错误。
  • 验证Worker是否接收到预期的请求头(例如X-OA-Internal-Key),以及为何返回“未授权”。
  • 查看Rust API或Web应用程序中的console.log / console_error!输出。
  • 与Convex日志关联分析(Convex会调用API Worker;复现问题时可同时查看API Worker的日志)。

Workers in this repo

本仓库中的Worker

WorkerConfigRoutesPurpose
openagents-api
apps/api/wrangler.toml
openagents.com/api/*
Rust API: openclaw, control, D1, R2, etc.
openagents-web-app
apps/web/wrangler.jsonc
openagents.com
(main site)
TanStack/React app (Node compat).
Run
wrangler tail
from the app directory that contains that worker's config (or use
--config
/
--cwd
).
Worker配置文件路由用途
openagents-api
apps/api/wrangler.toml
openagents.com/api/*
Rust API:负责openclaw、控制、D1、R2等功能。
openagents-web-app
apps/web/wrangler.jsonc
openagents.com
(主站点)
TanStack/React应用(兼容Node)。
在包含该Worker配置文件的应用目录中运行
wrangler tail
命令(或使用
--config
/
--cwd
参数指定路径)。

Wrangler tail (real-time only)

Wrangler tail(仅实时日志)

Cloudflare does not provide historical Worker logs via the CLI. You get a live stream of requests and logs. For historical data, use the dashboard: Workers & Pages → your worker → Logs / Real-time Logs or Logpush.
Cloudflare通过CLI提供Worker的历史日志。你只能获取请求和日志的实时流。如需查看历史数据,请使用Cloudflare控制台:Workers & Pages → 你的Worker → 日志/实时日志 或 Logpush功能。

Basic usage

基本用法

bash
undefined
bash
undefined

API worker (Rust) — run from apps/api

API worker (Rust) — 从apps/api目录运行

cd apps/api npx wrangler tail
cd apps/api npx wrangler tail

Web app worker — run from apps/web

Web app worker — 从apps/web目录运行

cd apps/web npx wrangler tail

Leave the command running, then reproduce the issue in the browser. You'll see each request, status, and any console output.
cd apps/web npx wrangler tail

保持命令运行,然后在浏览器中复现问题。你将看到每个请求、状态以及所有控制台输出。

Tail options

日志查看参数

OptionMeaning
--format pretty
Human-readable (default).
--format json
One JSON object per log line (e.g. pipe to
jq
).
--status ok
Only successful requests.
--status error
Only errors/failures.
--method GET
Filter by HTTP method.
--search "openclaw"
Filter by text in console.log messages.
--header "x-oa-internal-key"
Filter by presence of header.
--sampling-rate 1
Log 100% of requests (default can sample).
参数说明
--format pretty
人类可读格式(默认)。
--format json
每行日志为一个JSON对象(例如可通过管道传递给
jq
处理)。
--status ok
仅显示成功的请求。
--status error
仅显示错误/失败的请求。
--method GET
按HTTP方法过滤。
--search "openclaw"
按console.log消息中的文本内容过滤。
--header "x-oa-internal-key"
按是否存在指定请求头过滤。
--sampling-rate 1
记录100%的请求(默认情况下可能会采样)。

Examples

示例

bash
undefined
bash
undefined

API worker: only errors, pretty

API worker: 仅查看错误日志,使用易读格式

cd apps/api npx wrangler tail --status error --format pretty
cd apps/api npx wrangler tail --status error --format pretty

API worker: JSON and filter by URL path with jq

API worker: 以JSON格式输出并通过jq按URL路径过滤

cd apps/api npx wrangler tail --format json | jq 'select(.url | contains("openclaw"))'
cd apps/api npx wrangler tail --format json | jq 'select(.url | contains("openclaw"))'

Web worker: tail while reproducing a page error

Web worker: 复现页面错误时查看日志

cd apps/web npx wrangler tail
undefined
cd apps/web npx wrangler tail
undefined

Two workers, two terminals

同时查看两个Worker的日志:使用两个终端

To see both the site and the API when debugging a flow (e.g. Hatchery calling Convex, Convex calling API):
  1. Terminal 1:
    cd apps/api && npx wrangler tail --format pretty
  2. Terminal 2:
    cd apps/web && npx wrangler tail --format pretty
  3. Optional: Convex logs in a third terminal:
    cd apps/web && npx convex logs --prod --success
Then reproduce; watch for the request to the API worker and any
console.log
/ diagnostic output.
当调试一个完整流程(例如Hatchery调用Convex,Convex调用API)时,如需同时查看站点和API的日志:
  1. 终端1:
    cd apps/api && npx wrangler tail --format pretty
  2. 终端2:
    cd apps/web && npx wrangler tail --format pretty
  3. 可选:在第三个终端查看Convex日志:
    cd apps/web && npx convex logs --prod --success
然后复现问题;观察API Worker的请求以及所有
console.log
/ 诊断输出。

Limitations

局限性

  • Real-time only: No
    --history
    ; tail streams until you Ctrl+C.
  • Sampling: Under heavy load, tail may sample; use
    --sampling-rate 1
    to reduce sampling.
  • Max 10 clients: Up to 10 concurrent tail sessions per worker.
  • Secrets: Logs must not print secrets; use lengths or "present/absent" in diagnostic logs.
  • 仅支持实时查看:没有
    --history
    参数;日志流会持续到你按下Ctrl+C停止。
  • 采样机制:在高负载情况下,日志可能会被采样;使用
    --sampling-rate 1
    参数可减少采样。
  • 最多10个客户端:每个Worker最多支持10个并发的日志查看会话。
  • 敏感信息:日志中禁止打印敏感信息;在诊断日志中可使用长度描述或“存在/不存在”来替代具体值。

Diagnostic logging (this repo)

诊断日志(本仓库)

For openclaw auth, the API worker logs:
  • openclaw auth: no internal key header path=...
    — request reached the worker but the
    X-OA-Internal-Key
    header was missing (e.g. stripped or not sent by Convex).
  • openclaw auth 401: path=... provided_len=... expected_len=...
    — header was present but value didn’t match the worker secret (compare lengths; if equal, values differ).
  • openclaw auth ok path=... key_len=...
    — internal key matched; request was authorized.
Use
wrangler tail
from
apps/api
while reproducing 401 to see which line appears. Convex actions log
[openclawApi <label>] fetch key_len=<n> url=...
before each request; correlate with worker logs to confirm what Convex sent vs what the worker received.
对于openclaw认证,API Worker会记录以下日志:
  • openclaw auth: no internal key header path=...
    — 请求已到达Worker,但缺少
    X-OA-Internal-Key
    请求头(例如被Convex剥离或未发送)。
  • openclaw auth 401: path=... provided_len=... expected_len=...
    — 请求头存在,但值与Worker的密钥不匹配(对比长度;如果长度相同,则说明值不同)。
  • openclaw auth ok path=... key_len=...
    — 内部密钥匹配;请求已通过认证。
复现401错误时,在
apps/api
目录下运行
wrangler tail
即可查看上述日志行。Convex动作会在每次请求前记录
[openclawApi <label>] fetch key_len=<n> url=...
;将该日志与Worker日志关联分析,可确认Convex发送的内容与Worker接收的内容是否一致。