惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Webroot Blog
Webroot Blog
AI
AI
P
Palo Alto Networks Blog
Attack and Defense Labs
Attack and Defense Labs
WordPress大学
WordPress大学
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
Spread Privacy
Spread Privacy
T
Tor Project blog
罗磊的独立博客
小众软件
小众软件
S
Security Affairs
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
NISL@THU
NISL@THU
博客园_首页
PCI Perspectives
PCI Perspectives
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
N
News and Events Feed by Topic
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Forbes - Security
Forbes - Security
博客园 - 叶小钗
D
Darknet – Hacking Tools, Hacker News & Cyber Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
L
LINUX DO - 热门话题
T
Threat Research - Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Security Latest
Security Latest
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Cloudflare Blog
A
About on SuperTechFans
爱范儿
爱范儿
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
TaoSecurity Blog
TaoSecurity Blog
宝玉的分享
宝玉的分享
G
GRAHAM CLULEY
雷峰网
雷峰网
F
Full Disclosure
I
Intezer
Cloudbric
Cloudbric
博客园 - 三生石上(FineUI控件)
U
Unit 42

Flavio Copes

Workers Cache: a cache in front of your Cloudflare Worker Cloudflare Drop: drag a folder, get a live site Temporary Cloudflare accounts: agents can now deploy without signing up Moondream 3.1 on Workers AI: fast vision at the edge inferencecost.dev: what will AI inference cost you at 10k users? Sitebase: all the features your website needs, in one place StackPlan: figure out where to deploy your app, and what it How the Cloudflare Pages build cache works The Summer of Code How I generate an Open Graph image for every post New: 90 free tools for developers How I added search to my static site with Pagefind How to rebuild a Cloudflare site on a schedule Cloudflare Email Workers: run code when an email arrives Cloudflare Turnstile: stop bots without annoying CAPTCHAs Cloudflare Workers: secrets and environments Cloudflare Analytics Engine: store and query metrics The AI Workshop (July 2026 cohort) Cloudflare Cron Triggers: run a Worker on a schedule Cloudflare Durable Objects: state that lives in one place Cloudflare Queues: run work in the background Cloudflare R2: object storage without egress fees Cloudflare KV: a key-value store for your Workers Cloudflare D1: a SQL database for your Workers Serving a website with Cloudflare Workers static assets Wrangler: the Cloudflare Workers command line tool Executor: one gateway to connect your AI agent to every tool Cloudflare Workers: your first serverless function Vercel eve: an open framework for building AI agents Flue: the open framework for building AI agents Val Town: write and deploy code in seconds A hands-on guide to The Agency, a collection of AI agents The AI Workshop (June 2026 cohort) The AI Workshop (May 2026 cohort) The AI Workshop (Apr 2026 cohort)
Cloudflare Workers observability: logs and traces
Flavio Copes · 2026-06-30 · via Flavio Copes

By Flavio Copes

Learn how to see what your Cloudflare Worker does in production using console.log, observability in wrangler.jsonc, and live tailing with wrangler tail.

~~~

Code that runs on someone else’s servers can feel like a black box. When something breaks in production, you need to see what happened.

Cloudflare Workers have observability built in: logs you can search, live tailing, and traces. Let me show you how I keep an eye on things.

Just use console.log

The simplest tool is the one you already know. console.log works in a Worker, and the output is captured for you:

export default {
  async fetch(request, env) {
    console.log('Handling', request.url)

    try {
      // ... your code ...
    } catch (err) {
      console.error('Something broke:', err)
    }

    return new Response('ok')
  },
}

console.error is good for problems, console.log for everything else.

Turn on observability

To keep your logs so you can search them later, enable observability in wrangler.jsonc:

{
  "observability": {
    "enabled": true,
    "logs": { "enabled": true }
  }
}

Now your logs are stored and searchable in the Cloudflare dashboard. You can filter by status, by message, by time. When a user reports a bug, you go look at what actually happened.

Watch logs live

When you’re actively debugging, you don’t want to refresh a dashboard. Stream the logs straight to your terminal:

npx wrangler tail

Every request and every console.log from your live Worker shows up as it happens. I keep this running in a terminal while I test a change in production.

You can filter, for example to only see errors:

npx wrangler tail --status error

Sampling for high traffic

If your Worker handles a lot of requests, logging every single one gets noisy and adds up. You can sample: keep a fraction of them.

{
  "observability": {
    "enabled": true,
    "logs": { "enabled": true, "head_sampling_rate": 1 },
    "traces": { "enabled": true, "head_sampling_rate": 0.01 }
  }
}

head_sampling_rate is a number from 0 to 1. 1 keeps everything. 0.01 keeps 1%.

I keep logs at 1 so I never miss an error, and traces at 0.01, since a small sample is enough to spot performance patterns.

Traces

That traces setting unlocks the other half of observability. A trace shows the timeline of a single request: how long the database query took, how long an external call took, where the time went.

Logs tell you what happened. Traces tell you why it was slow. Together they cover most of what you need to debug a live app.

My habit

I turn observability on from the very first deploy. It costs nothing to set up, and the day something goes wrong, having searchable logs and wrangler tail ready is the difference between a five-minute fix and an afternoon of guessing.

The full reference is in the observability docs.

~~~

Related posts about cloudflare: