Chapter 90. Verbose Logging Will Disturb Your Sleep

Johannes Brodwall

image with no caption

WHEN I ENCOUNTER A SYSTEM that has already been in development or production for a while, the first sign of real trouble is always a dirty log. You know what I’m talking about: when clicking a single link on a normal flow on a web page results in a deluge of messages in the only log that the system provides. Too much logging can be as useless as none at all.

If your systems are like mine, when your job is done, someone else’s job is just starting. After the system has been developed, it will hopefully live a long and prosperous life serving customers (if you’re lucky). How will you know if something goes wrong when the system is in production, and how will you deal with it?

Maybe someone monitors your system for you, or maybe you will monitor it yourself. Either way, the logs will probably be part of the monitoring. If something shows up and you have to be woken up to deal with it, you want to make sure there’s a good reason for it. If my system is dying, I want to know. But if there’s just a hiccup, I’d rather enjoy my beauty sleep.

For many systems, the first indication that something is wrong is a log message being written to some log. Mostly, this will be the error log. So do yourself a favor: make sure from day one that if something is logged in the error log, you’re willing to have someone call ...

Get 97 Things Every Programmer Should Know now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.