Picture yourself on a P1 incident call with 60 people. You’re triaging a revenue impacting failure of your service. The client is crashing on 1 out

The Promise and Peril of JSON logging

submited by
Style Pass
2024-05-13 08:00:04

Picture yourself on a P1 incident call with 60 people. You’re triaging a revenue impacting failure of your service. The client is crashing on 1 out of 3 requests, but your system is not alerting. You reach for your server logs to determine the reason for the failures but you find nothing useful. You’re just logging the route and status code which are all 200s. A pit opens up in your stomach as your boss demands an update.

As developers, we’re always logging. Sometimes it’s a console.log(“here”) used for local debugging sometimes it’s detailed HTTP logs used for ad-hoc queries on production app behavior at scale. In either case, the greater the detail and organization of your logs the better the picture you get of your application state.

There are many ways computers can tell us what’s going on. One is by simple single line statements that we define. See the above console.log(“here”) or maybe something slightly more helpful like log(“GET user/1234”) to indicate that our server has responded to an HTTP call with a GET verb and a defined route.

Leave a Comment