I don’t want to use Sentry for this current project I’m building. It’s a small private app with very limited memberships.
I want to use Workers Trace Events (I think) and push my logs to an R2 bucket. I see in the docs how to accomplish this but I’m confused as to the roll of a Tail worker in the process?
Or is the Tail Worker a completely different way to accomplish my goal.
Here’s what I’m thinking…
I want to send custom console.logs only when my Workers hits a non-200 response. I can send the internal function/handler that was being called and the endpoint that failed.
Would this be better accomplished in a Tail Worker or through Worker Trace Events?
Thanks for any help on getting some simple logging setup.
To log non-200 responses in Cloudflare Workers and send them to an R2 bucket, you can use Worker Trace Events. Here’s a simplified step-by-step guide:
In your Worker script, add logic to check the response status.
If the status is not 200, use console.log() to output the desired information.
Enable Trace Events in your Worker’s configuration.
Set up a Worker to listen for these Trace Events and write them to an R2 bucket.
The Tail Worker is a separate tool for real-time debugging and is not necessary for this logging setup. It’s more for live troubleshooting rather than storing logs.