Cloudflare Workers Logging with Papertrail

Art Krisada
2 min readNov 18, 2021

--

After I used Cloudflare Workers, I tried to find Log Management system. I came across Papertrail. It’s on the cloud, so you don’t have to maintain your own server for logging. Papertrail has free plan. So you can play with it.

First you need to signup. Then, you can login and find these.

In Dashboard page, You can add System and Create Group to manage separate log.

Next, get endpoint and token to POST your logs.

Select menu Settings > Account

Select Log Destination.

Copy Endpoint and Token.

Next step is put this in your code.

I add function postLog() to my Cloudflare Workers.

PAPERTRAIL_ENDPOINT is Endpoint in Log Destination we just copy.

PAPERTRAIL_API_TOKEN is Token in Log Destination also.

You can set these variables in wrangler.toml so you don’t have to put it in your code.

You can test with wrangler dev command and test at http://localhost:8787/

You can see the result in Event Page.

Papertrail might not have advance feature for log analysis but I think it’s quite easy to used.

--

--

Art Krisada
Art Krisada

Written by Art Krisada

Never stop learning, because life never stop teaching.

No responses yet