Best way to log 5xx and 4xx errors in workers?

We have built our first worker application and are planning the deployment to handle live traffic.

Our worker application provides all the application logic and serves the html and css, so there is no origin involved at all. Each request is fully served directly by the worker.

We are wondering how to log/record errors from the worker application, particularly 5xx and 4xx errors, if there are no log files to analyse like we get from our Nginx-based origin?

The requirement is to capture any errors so we can remediate them within the app.

You can install the Logflare app and it’ll log any 5xx and 4xx’s served to your users.

Additionally, Logflare has ingest endpoints to take any POST body so you can follow this guide to log anything you like:

Doing these two things will 1) setup logging on the “frontend” so you can easily see the request / response data getting served to your actual users and 2) setup logging on the “backend” to log anything additional you may want to from your code.

1 Like