worker-logs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCheck 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
| Worker | Config | Routes | Purpose |
|---|---|---|---|
| openagents-api | | | Rust API: openclaw, control, D1, R2, etc. |
| openagents-web-app | | | TanStack/React app (Node compat). |
Run from the app directory that contains that worker's config (or use / ).
wrangler tail--config--cwd| Worker | 配置文件 | 路由 | 用途 |
|---|---|---|---|
| openagents-api | | | Rust API:负责openclaw、控制、D1、R2等功能。 |
| openagents-web-app | | | TanStack/React应用(兼容Node)。 |
在包含该Worker配置文件的应用目录中运行命令(或使用 / 参数指定路径)。
wrangler tail--config--cwdWrangler 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
undefinedbash
undefinedAPI 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
日志查看参数
| Option | Meaning |
|---|---|
| Human-readable (default). |
| One JSON object per log line (e.g. pipe to |
| Only successful requests. |
| Only errors/failures. |
| Filter by HTTP method. |
| Filter by text in console.log messages. |
| Filter by presence of header. |
| Log 100% of requests (default can sample). |
| 参数 | 说明 |
|---|---|
| 人类可读格式(默认)。 |
| 每行日志为一个JSON对象(例如可通过管道传递给 |
| 仅显示成功的请求。 |
| 仅显示错误/失败的请求。 |
| 按HTTP方法过滤。 |
| 按console.log消息中的文本内容过滤。 |
| 按是否存在指定请求头过滤。 |
| 记录100%的请求(默认情况下可能会采样)。 |
Examples
示例
bash
undefinedbash
undefinedAPI 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
undefinedcd apps/web
npx wrangler tail
undefinedTwo workers, two terminals
同时查看两个Worker的日志:使用两个终端
To see both the site and the API when debugging a flow (e.g. Hatchery calling Convex, Convex calling API):
- Terminal 1:
cd apps/api && npx wrangler tail --format pretty - Terminal 2:
cd apps/web && npx wrangler tail --format pretty - 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 / diagnostic output.
console.log当调试一个完整流程(例如Hatchery调用Convex,Convex调用API)时,如需同时查看站点和API的日志:
- 终端1:
cd apps/api && npx wrangler tail --format pretty - 终端2:
cd apps/web && npx wrangler tail --format pretty - 可选:在第三个终端查看Convex日志:
cd apps/web && npx convex logs --prod --success
然后复现问题;观察API Worker的请求以及所有 / 诊断输出。
console.logLimitations
局限性
- Real-time only: No ; tail streams until you Ctrl+C.
--history - Sampling: Under heavy load, tail may sample; use to reduce sampling.
--sampling-rate 1 - 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.
- 仅支持实时查看:没有参数;日志流会持续到你按下Ctrl+C停止。
--history - 采样机制:在高负载情况下,日志可能会被采样;使用参数可减少采样。
--sampling-rate 1 - 最多10个客户端:每个Worker最多支持10个并发的日志查看会话。
- 敏感信息:日志中禁止打印敏感信息;在诊断日志中可使用长度描述或“存在/不存在”来替代具体值。
Diagnostic logging (this repo)
诊断日志(本仓库)
For openclaw auth, the API worker logs:
- — request reached the worker but the
openclaw auth: no internal key header path=...header was missing (e.g. stripped or not sent by Convex).X-OA-Internal-Key - — header was present but value didn’t match the worker secret (compare lengths; if equal, values differ).
openclaw auth 401: path=... provided_len=... expected_len=... - — internal key matched; request was authorized.
openclaw auth ok path=... key_len=...
Use from while reproducing 401 to see which line appears. Convex actions log before each request; correlate with worker logs to confirm what Convex sent vs what the worker received.
wrangler tailapps/api[openclawApi <label>] fetch key_len=<n> url=...对于openclaw认证,API Worker会记录以下日志:
- — 请求已到达Worker,但缺少
openclaw auth: no internal key header path=...请求头(例如被Convex剥离或未发送)。X-OA-Internal-Key - — 请求头存在,但值与Worker的密钥不匹配(对比长度;如果长度相同,则说明值不同)。
openclaw auth 401: path=... provided_len=... expected_len=... - — 内部密钥匹配;请求已通过认证。
openclaw auth ok path=... key_len=...
复现401错误时,在目录下运行即可查看上述日志行。Convex动作会在每次请求前记录;将该日志与Worker日志关联分析,可确认Convex发送的内容与Worker接收的内容是否一致。
apps/apiwrangler tail[openclawApi <label>] fetch key_len=<n> url=...